April 2018
Intermediate to advanced
300 pages
7h 41m
English
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;