18、C 语句详解
2026/6/6 21:03:21 网站建设 项目流程

C# 语句详解

1. 开关语句(Switch Statement)

开关语句允许根据变量的值执行不同的代码块。以下是一个开关语句的示例:

for( int x=1; x<6; x++ ) { switch( x ) // Evaluate the value of variable x. { case 2: // If x equals 2 Console.WriteLine ("x is {0} -- In Case 2", x); break; // Go to end of switch. case 5: // If x equals 5 Console.WriteLine ("x is {0} -- In Case 5", x); break; // Go to end of switch. default: // If x is neither 2 nor 5

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询