Control cannot fall through from one case label

前端 未结 8 1250
旧巷少年郎
旧巷少年郎 2020-11-27 05:50

I am trying to write a switch statement that would type the search term in the search field depending on whichever search textbox is present. I have the following code. But

8条回答
  •  时光取名叫无心
    2020-11-27 06:05

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Case_example_1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Char ch;
                Console.WriteLine("Enter a character");
                ch =Convert.ToChar(Console.ReadLine());
                switch (ch)
                {
                    case 'a':
                    case 'e':
                    case 'i':
                    case 'o':
                    case 'u':
                    case 'A':
                    case 'E':
                    case 'I':
                    case 'O':
                    case 'U':
    
                        Console.WriteLine("Character is alphabet");
                        break;
    
                    default:
                        Console.WriteLine("Character is constant");
                        break;
    
                }
    
                Console.ReadLine();
    
            }
        }
    }
    

提交回复
热议问题