c#学习笔记(一)

来源:互联网 发布:汉服 知乎 编辑:程序博客网 时间:2024/05/06 22:29

C#的基本知识

一、定义变量:
string strExample; 字符串("aaa")
char chrExample; 字符('a')
bool blnExample; Bool型(true/false)
DataTime datExample; 日期型("09/19/2002")
int intExample; 整数(32位有符号整数)
double dblExample; 浮点数(64位双精度浮点数)
二、各种运算:
= 赋值运算
+ 加法运算
- 减法运算
* 乘法运算
/ 除法运算
% 取模运算
&& 逻辑And
|| 逻辑Or
! 逻辑Not
三、各种结构:
if(条件)
{
}
else
{
}

switch(条件)
{
case option1:
    break;
case option2:
    break;
}

for(int i=1;i<=10;i++)//特别注意这里面是分号
{
}

while(条件)
{
}

do
{
}while(条件);