What does it mean to add a question mark after a data type in a C # entity class

Source: Internet
Author: User
What does it mean to add a question mark after a data type in a C # entity class
Public DateTime? createtime{  set {_createtime = value;} get {return _createtime;}}

A question mark (?) in the C # syntax. An operator is a type that can be null.
 explanation above:
when working with databases and other data types that contain elements that are not assignable, it is particularly useful to assign NULL to numeric or Boolean and date-type features. For example, a Boolean field in a database can store a value of true or false, or the field may not be defined.
two question marks (??) in the C # syntax Operator is a null merge operator, and the merge operator defines a preset value for a type conversion to prevent null values for nullable types.
MSDN explanation above:
?? Operators are called null Merge operators, which define the default values for types and reference types that can be null values. If the left-hand operand of this operator is not NULL, this operator returns the left operand (the left expression), otherwise the right operand (the right expression) when the left-hand operand is null.
Related Article

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.