Follow the steps for checking the null values in C#:
1. Create the variable first. A variable should be declared before using it. You can use the following code for creating the variable :
Code:
string myNullVar = null;
2. After that you will have to make sure that whether the variable is null or not. You can use the following code for that purpose :
Code:
if(myNullVar == null) {
myNullVar = "RED";
} 3. Then you will have to check if the variable is not null. In a few cases, you may want to relocate the variable back to null. The following code is useful for that :
Code:
if(myNullVar != null) {
myNullVar = null;
}
Bookmarks