官术网_书友最值得收藏!

Constant pattern

A constant pattern is a simple pattern that checks for the constant value. Consider the following example: if the Person object is null, it will return and exit the body method.

The Person class is as follows:

class Person 
{ 
  public int ID { set; get; } 
  public string Name { get; set; } 
 
  public DateTime DOB { get; set; } 
} 

In the preceding code snippet, we have a Person class that contains three properties, namely ID, Name, and DOB (Date of Birth).

The following statement checks for the person object with a null constant value and returns it if the object is null:

if (person is null) return; 
主站蜘蛛池模板: 阜宁县| 尖扎县| 林西县| 万年县| 贵州省| 剑河县| 潮州市| 宣威市| 错那县| 双桥区| 垫江县| 安西县| 杭锦后旗| 天水市| 周至县| 德昌县| 湘阴县| 阿城市| 连山| 三台县| 微山县| 辽宁省| 平定县| 云梦县| 定州市| 黄骅市| 平谷区| 内黄县| 大宁县| 乐平市| 台前县| 黑水县| 黄陵县| 吐鲁番市| 阳曲县| 怀安县| 锦州市| 门源| 肥乡县| 库车县| 兰州市|