How to use switch case statement with char value in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            char ch = 'a';

            switch (ch)
            {
                case 'a':
                    Console.WriteLine("a");
                    break;
                case 'b':
                    Console.WriteLine("b");
                    break;
                default:
                    Console.WriteLine("default");
                    break;
            }
        }
    }
}


/*
run:
 
a
 
*/

 



answered Dec 30, 2016 by avibootz

Related questions

2 answers 376 views
3 answers 421 views
2 answers 348 views
3 answers 373 views
2 answers 367 views
2 answers 350 views
...