C#中的if语句
来源:互联网 发布:长歌正太捏脸数据 编辑:程序博客网 时间:2024/05/21 09:43
if语句的使用方法:
- if (condition) *这里的condition可以是一个bool类型的值,也可以是最终值为bool类型的表达式。
statements ; *statements是如果condition为真是需要执行的语句,如果不为真则跳过这段语句向后执行。 - statements 如果是一条语句则不需要在statements的起始位置添加一对"{}",如果statements为多条语句则必须使用"{}"将这段语句括起来。
using System;namespace IfDemo{class Program{static void Main(){Console.WriteLine("Please input a string:");string input = Console.ReadLine();if(input == ""){Console.WriteLine("You typed in an empty string!");return ;} else if(input.Length < 10) //这里的 else if 可以根据需要添加多个{Console.WriteLine("The string had less than 10 characters.");} else if(input.Length < 10){Console.WriteLine("The string had at least 10 but less than 20 characters.");}else { //这里的else 只能有一个Console.WriteLine("The string had more than 20 characters.");}Console.WriteLine("The string was {0}",input);Console.ReadKey();}}}
- C#中的if语句
- C#中的分支结构:if..else if 、if... else 和 switch ...case语句的区别
- c#中if语句
- c#之if语句
- jsp中的if语句
- 批处理中的if语句
- shell中的if语句
- mysql中的if语句
- shell 中的if语句
- javascript中的if语句
- javascript中的if语句
- matlab中的if语句
- shell 中的if语句
- newlisp中的if语句
- shell中的if语句
- java中的if语句
- mybatis中的if语句
- 查询语句中的if
- MYsql压力测试脚本
- Write operations are not allowed in read-only mode 只读模式下(FlushMode.NEVER/MANUAL)写操作不允
- cookies 第一方cookie 和 第3方cookie
- C/Java/C++数据类型的比较
- sql基本语句整理
- C#中的if语句
- 人生就是一个人的较量
- linux隐式密码输入
- 在DLL编程中,导出函数为什么需要extern "C"
- 连接ACCESS
- Deploying OpenStack-第一章 OpenStack项目
- ORA-24324 ORA-01041 ORA-03113
- QVGA/HVGA/WVGA/FWVGA分辨率屏含义及大小//Android虚拟机分辨率
- 信号驱动(SIGIO)的异步I/O