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 252 views
3 answers 279 views
2 answers 234 views
3 answers 224 views
2 answers 236 views
2 answers 216 views
...