2014年3月7日
摘要: 1. ? – Nullable1[SerializableAttribute]2public struct Nullable where T : struct, new()C#里像int, bool, double这样的struct和enum类型都不能为null。如果确实想在值域上加上null的话,Nullable就派上用场了。T?是Nullable&ly;T>的语法糖。要将T?转为T可以通过类型转换,或者通过T?的Value属性,当然后者要高雅些。1// Nullable arg = -1;2int? arg = -1;3if (arg.HasValue) {4// int v 阅读全文
posted @ 2014-03-07 12:03 Kein 阅读(688) 评论(0) 推荐(0) 编辑