C# 中的switch 语句
帮我看看这个程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("please input a character!");
char ch = (char)Console.Read();
switch (ch)
{
case 'a':
Console.WriteLine("the character is a");
case 'b':
Console.WriteLine("the character is b");
default :
Console.WriteLine("charcater is not define");
}
}
}
}
编译报错如下:
Error 1 Control cannot fall through from one case label ('case 'a' (0x61):') to another D:\Backup\我的文档\Visual Studio 2008\Projects\array\ConsoleApplication2\Program.cs 20 17 ConsoleApplication2
Error 2 Control cannot fall through from one case label ('case 'b' (0x62):') to another D:\Backup\我的文档\Visual Studio 2008\Projects\array\ConsoleApplication2\Program.cs 22 17 ConsoleApplication2
Error 3 Control cannot fall through from one case label ('default:') to another D:\Backup\我的文档\Visual Studio 2008\Projects\array\ConsoleApplication2\Program.cs 24 17 ConsoleApplication2