System.Nullable<T> What is the value of null * int value?
问题 Consider the following statements: int? v1 = null; int? v2 = 5 * v1; What is the value of v2 ? ( null or empty string?) How can I prevent the compiler to mark it as invalid operation? Do I need to follow custom exception handling? 回答1: It's null . C# Language Specification 3.0 (Section §7.2.7: Lifted operators) For the binary operators + - * / % & | ^ << >> : a lifted form of an operator exists if the operand and result types are all non-nullable value types. The lifted form is constructed by