none
btn.IsChecked ?? false 这种写法什么意思?头一次看到 RRS feed

答案

  • The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand. Remarks A nullable type can contain a value, or it can be undefined. The ?? operator defines the default value to be returned when a nullable type is assigned to a non-nullable type. If you try to assign a nullable type to a non-nullable type without using the ?? operator, you will generate a compile-time error. If you use a cast, and the nullable type is currently undefined, an InvalidOperationException exception will be thrown. 简单来说就是Ischecked是null的时候赋值false,非null的时候赋值Ischeck的值.
    2011年8月12日 2:25

全部回复

  • The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand. Remarks A nullable type can contain a value, or it can be undefined. The ?? operator defines the default value to be returned when a nullable type is assigned to a non-nullable type. If you try to assign a nullable type to a non-nullable type without using the ?? operator, you will generate a compile-time error. If you use a cast, and the nullable type is currently undefined, an InvalidOperationException exception will be thrown. 简单来说就是Ischecked是null的时候赋值false,非null的时候赋值Ischeck的值.
    2011年8月12日 2:25
  • 参考: http://msdn.microsoft.com/zh-cn/library/ms173224.aspx


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2011年8月14日 17:42
    版主