We use Fortify to scan the code for our application. In one particular code as shown below
dr["test"] = GetTest(temp.Type!.Substring(0, 1));
Fortify throws null Deference error. So, I changed the code as shown below
dr["test"] = GetTest(temp.Type.Length > 0 ? temp.Type!.Substring(0, 1) : temp.Type);
though I am getting the same Null Deference error. I googled some codes related to null deference but I did not get the exact solution.