zoukankan      html  css  js  c++  java
  • 【你吐吧c#每日学习】10.30 C#Nullable Types

    分两种类型,value type and reference type.

    By default, value type owns a default value. For integer, the default value is 0. The value type can't be null. Non nullable

    But for reference types, included class, interface, delegates, arrays, objects, 这些引用类型可以=null。Nullable

    ? to make non nullable type nullable.

    (typeName)to make nullable type non nullable(explicit conversion).

    但是有时候值类型也需要等于空值呀,だから?を採用する。

    bool IsMajor

    bool? IsMajor=null

    当一个是非的问题bool值表示用户的选择yes or no option,用户没有选择的时候

    if(IsMajor==true){

    }else

    if(IsMajor==false) or if(!IsMajor.value){

    }else{Console.WriteLine("User is not answer the que")}

    ?? Null coalescing operator

    int? a=10;

    int b=a??0; equals{

    if(a==null){b=0;}else{b=a.Value; or b=(int)a;} //Direct Assignment will be fault. b=a

    }

    Double Question Mark

  • 相关阅读:
    python
    C++的socket编程学习
    GooglePlay
    GooglePlay
    Admob
    cocos2dx
    cocos2dx
    cocos2dx
    cocos2dx
    浅谈白鹭Egret
  • 原文地址:https://www.cnblogs.com/jin-wen-xin/p/4063443.html
Copyright © 2011-2022 走看看