C # In depth Third Edition Study Notes -- null type

Source: Internet
Author: User

1. What if there is no value?

The customer placed an order with an order date but not yet delivered, but there was no delivery date. How can we express the delivery date? C #2 and later can be empty type.

2. Why cannot a value-type variable be null?

A reference type variable whose value is a reference. That is, a non-null reference value provides a way to access an object. For null, being a special value means that no object is referenced. All referenced default values are null, indicating that all values are zero in memory.

Value Type Variable. Its value is its actual data. Null is not a valid value.

3. C #1 solve the non-null type

Magic value: datetime, at the expense of a value datetime. minvalue in the first year of the year.

Reference Type packaging: requires packing and unpacking

Extra Boolean flag: It is generally used to encapsulate the value and flag into another value type.

4. system. nullable <t> and system. nullable

Nullable <t> is a generic type and T has a value type constraint. Therefore, nullable <stream> or nullable <nullalbe <int> cannot be used. It has two important attributes: hasvalue and value. Nullable <t> is still a value type.

? Modifier: Int? Nullable = 5;

Use the as operator for the null type: null or meaningful value.

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.