C#中简单的if else条件语句使用范例
可以下载附件运行和查看执行结果
using System; public class SampleClass { public static void Main() { int num1 = 61; int num2 = 231; int res = num1 + num2; if (res > 252) { res = res - 50; Console.WriteLine("Result is more then 252"); } else { res = 252; Console.WriteLine("Result is less then 252"); } bool b = true; if (res > 252 || b) Console.WriteLine("Res > 252 or b is true"); else if ( (res>252) && !b ) Console.WriteLine("Res > 252 and b is false"); else Console.WriteLine("else condition"); } }
附件:源代码下载