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

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; 
主站蜘蛛池模板: 清苑县| 乳源| 安仁县| 武邑县| 大同县| 东乡族自治县| 永和县| 宜宾市| 大丰市| 新疆| 阿坝| 宝应县| 新乡县| 云林县| 华安县| 黄浦区| 宜章县| 巴南区| 宝坻区| 将乐县| 綦江县| 福海县| 三门县| 镇江市| 天长市| 萍乡市| 阿拉善右旗| 晋宁县| 南和县| 南皮县| 烟台市| 镇平县| 大丰市| 大化| 自贡市| 鞍山市| 博乐市| 蒲江县| 秦皇岛市| 马龙县| 法库县|