The null interface operator provides a shortcut to indicate null when processing null and reference types. This operator is placed between two operands. The first operation must be of a null or reference type, and the second operation must be of the same type as the first operation, alternatively, it can be implicitly converted to the type of the first operand. The null operation operator is calculated as follows: if the first operand is not null, the entire expression is equal to the value of the first operand. However, if the first operand is null, the entire expression is equal to the value of the second operand. Int ? A = Null ;
Int B;
B = A ?? 10 ;
Console. writeline (B. tostring ());
A = 100 ;
B = A ?? 10 ;
Console. writeline (B. tostring ());
Console. Read ();
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