Resolve type and add question mark and double question mark

Source: Internet
Author: User

The type in the variable definition is followed by a question mark, meaning that the data type is of type nullable. When setting an initial value for a variable, assign a value of NULL to the variable (int type), not to 0!

Example:

Int? i = 3 equals to nullable<int> i = new nullable<int> (3);

An int? is another way to nullable<int> a generic type.

Null values are allowed when defining a method:


 Public  voidAddUser (stringNamestringPasswordint?role) {      //content slightly ...}      //UseAddUser ("Xiao Ming","123456",NULL);//default NULL for non-audited usersAddUser ("Xiao Wang","123456",1);//AdministratorAddUser ("How to ask","123456",2);//Normal UserView Plaincopy to Clipboardprint? Public voidAddUser (stringNamestringPasswordint?role) {      //content slightly ...}    //UseAddUser ("Xiao Ming","123456",NULL);//default NULL for non-audited usersAddUser ("Xiao Wang","123456",1);//AdministratorAddUser ("How to ask","123456",2);//Normal User

2. Variable definition in the type after the two question mark, used to determine and assign a value, the first to determine whether the current variable is null, if it is possible to assign a new value, otherwise skip! Means to take the assigned value?? To the left, if NULL on the left, take the assigned value?? On the right.

Example: Page?? 0, which indicates that the page is null, take the right value of 0.

Recommendation: http://www.cnblogs.com/roucheng/p/3562327.html

Resolve type and add question mark and double question mark

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.