标签:style blog http color 使用 strong
【可空类型】
Nullable types are instances of the System.Nullable<T> struct. A Nullable<bool> can be assigned the values true false, or null. The ability to assign null to numeric and Boolean types is especially useful when you are dealing with databases and other data types that contain elements that may not be assigned a value.
class NullableExample { static void Main() { int? num = null; // Is the HasValue property true? if (num.HasValue) { System.Console.WriteLine("num = " + num.Value); } else { System.Console.WriteLine("num = Null"); } // y is set to zero int y = num.GetValueOrDefault(); // num.Value throws an InvalidOperationException if num.HasValue is false try { y = num.Value; } catch (System.InvalidOperationException e) { System.Console.WriteLine(e.Message); } } }
??可配置可空类型使用:
参考:http://msdn.microsoft.com/zh-cn/library/1t3y8s4s.aspx
标签:style blog http color 使用 strong
原文地址:http://www.cnblogs.com/tekkaman/p/3856099.html