Contoh Program Menu Perulangan Menggunakan Do While pada C# (CSharp)

Ini Adalah Syntaxnya :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Menu
{
    class Program
    {
        static void Main(string[] args)
        {
            ConsoleKey plh;

            do
            {
                Console.WriteLine("Pilihan Menu : ");
                Console.WriteLine("1. Insert");
                Console.WriteLine("2. View");
                Console.WriteLine("3. Edit");
                Console.WriteLine("4. Delete");
                Console.WriteLine("5. Search");
                Console.WriteLine("6. Exit");
                Console.Write("Masukkan Menu Pilihan : ");
                plh = Console.ReadKey(true).Key;

                switch (plh)
                {
                    case ConsoleKey.D1:

                        Console.WriteLine("\nMasukkan Data");
                        break;
                    case ConsoleKey.D2:
                        Console.WriteLine("\nIsi Data");
                        break;
                    case ConsoleKey.D3:
                        Console.WriteLine("\nEdit");
                        break;
                    case ConsoleKey.D4:
                        Console.WriteLine("\nDelete");
                        break;
                    case ConsoleKey.D5:
                        Console.WriteLine("\nSearch");
                        break;
                    case ConsoleKey.D6:
                        Console.Clear();
                        Console.Write("Exit...");
                        break;

                    default:
                        Console.WriteLine("\nYang anda Input Salah");
                        break;
                }

            }

            while (plh != ConsoleKey.D6);
            Console.ReadKey();
        }
    }
}

Tampilannya :


Previous
Next Post »
Thanks for your comment