This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16806|Reply: 1

[Communication] C# 3.0 get set default

[Copy link]
Posted on 12/26/2016 3:16:18 PM | | | |
Article: http://blog.csdn.net/scauscnu/article/details/13621137
This has to say { get; set; }, because there is no private self-segment, we cannot manually specify the default value, so what is the default value of the system?

For int types, the default value is 0;
For int? type, the default value is null;
For bool types, the default value is false;
For bool? type, the default value is null;
For the String type, the default value is null;
For string? Type, haha, without this way of writing, there will be mistakes;
For the DateTime type, the default value is 0001-01-01 00:00:00;
For DateTime? type, the default value is null;
For enum types, the default value is an item with a value of 0, if an enum item with 0 does not exist, it is still 0, see C# Enums;
For enums? type, the default value is null;
For class types, the default is an uninstantiated object reference;
For class? Type, haha, without this way of writing, there will be mistakes.
Regarding the type plus ?, it means that the value of this type can be null, for example, int originally has no null value, plus int? It can be null.




We directly imitate and write,



Exception is thrown: Process is terminated due to StackOverflowException.

This kind of article is really misleading if you don't practice it yourself!!






Previous:Alipay AR real-life red envelope vulnerability cracked, grab VR red envelopes
Next:Isn't there a handheld forum in the mission? Where to download? I can't find !!
 Landlord| Posted on 12/26/2016 3:23:26 PM |
Correct way to assign defaults:





Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com