1. 整数增加了各种无符号类型,从后缀区分如下:
uint、ulong:U\u u|\ul
2. 字符串类型
a. 常规字符串 “ 我说:\"你好,\\我走了\" “ 需转义字符串,转义显示
b. 逐字字符串 @“ 我说:“”你好,\我走了 “” ” 串内字符除引号外全部直接显示,不转义。
3. 比较运算符:浅比较、深比较(字符串、委托)
4. 用户定义的转换类型
a. 隐式转换:
public static implicit operator TargetType (SourceType value)
{
return TargetTypeValue;
}
b. 显示转换:
public static explicit operator int (LimitedInt value)
{
return li.TheValue;
}
c. 二者区别
1) 定义关键字区别 implicit、explicit
2) 使用区别
LimitedInt limitedInt = 5;
int value = limitedInt;// 隐式转换
LimitedInt limitedInt = 5;
int value = (int)limitedInt;// 显示转换
5. 支持运算符重载:
+、-、!、~、++、--、true、false;
*、/、%、&、|、^、<<、>>、==、!=、>、<、>=、<=;
public static Second operator + (Second second, int up) {
Second result = second;
result.age += up - 2;
return result;
}
6. typeOf运算符,类似反射概念,不可被重载。
7. switch, case 没有跳转语句不允许包含任何语句,如果需要,可跳转到其他case:goto case 2;
8. using语句结合IDisposed接口,实现资源自动处置操作。
using (ResourceType Identifier = Expression, <span style="font-family: Arial, Helvetica, sans-serif;">Identifier2 = Expression</span>)
{
...
}
ResourceType Identifier = Expression;// 在语句外创建,释放后可能仍然使用,不推荐此方式
using (Identifier)
{
...
}
9. 待补充:
checked、unchecked、yield、foreach、try\throw\finally