运算符
一元运算符
二元运算符
将加法运算符用于字符串。
在算数运算符中使用字符。
int n='3'+'4';
char c=(char)n;
浮点类型的特殊性
不精确
非数字:-1f/0==>负无穷大
圆括号()
赋值运算符=
递增递减++ --
**线性安全的递增和递减(System.Threading.Interlocked)
Increament()
Decreament()
常量表示式(constant expression)
const 关键字会在编译时将值锁定。
const int intConstNum=60*3;
流控制语句
if()
while()
do while()
for()
foreach(in):遍历数据项集合
continue
switch:判断的test-expression与控制数值类型兼容的一个值。从sbyte--ulong,char, string,menu;
break
作用域和声明空间
作用域 scope
声明空间 declaration space
布尔表达式
关系运算符和相等性运算符 :< <= > >= == !=
逻辑布尔运算符: || && ^
逻辑求反 :!
条件运算符:conditional?consequence:alternative
空接运算符(null coalescing operator):expression1??expression2;
检查第一个表达式是否为null,如果为null,就返回第二个表示式。
按位运算符:
移位:<< >>
运算:& | ~ ^
预处理指令(不熟悉)
#if
//排除和包含代码
#if CSHARP2
System.Console.Clear();
#endif
#elif
#if LINUX
……
#elif WINDOWS
……
#endif
#else
#define
#define CSHARP2
#undef
#error
#warning
//生成错误和警告
#warning "same move allowed mutiple times"
#pragma
//关闭警告消息
#pragma warning disable 1030
//还原一个警告
#pragma warning restore 1030
#line
//可以改变C#编译器在报告错误或者警告时显示的行号。
#line 113 "XXX.cs"
#warning "same move allowed mutiple times"
#line default
#region #endregion