title: Object reference not set to an instance of an object in c# how to check for null value?
body: <p>I am getting nullrefernce exception after running c# code at this line </p>
  
  <pre><code>  var data = info.details.Split('|');
  </code></pre>
  
  <p>c# code:</p>
  
  <pre><code> public studentinfo SaveData(studentinfo info)
          {
              bool returnBool=false;
              SqlConnection con;
  
                  var data = info.details.Split('|');
  
  
                  var response = new studentinfo
                  {
                      ID = data[0],
                      Name = data[1],
                      Project = data[2],
                      Result = data[3]
                  };
  
  
              con = new SqlConnection(ConfigurationManager.ConnectionStrings["Myproject.Properties.Settings.MyConnection"].ConnectionString);
  
              string sqlStr = "INSERT INTO Result (ID,Name,Project,Result) values('" + data[0] + "', '" + data[1] + "', '" + data[2] + "', '" + data[3] + "')";
              SqlCommand dbCommand = new SqlCommand(sqlStr, con);
  
               try
              {
                  con.Open();
                  if (dbCommand.ExecuteNonQuery() != 0)
                  {
                      returnBool = true;
                  }
  
                  if (!data.Equals(null))
                  {
                      returnBool = true;
                  }
                  con.Close();
              }
              catch
              {
                 returnBool= false;
              }
               con.Close();
               return response;
  
          }
  </code></pre>
  
  <p>I tried to implement:</p>
  
  <pre><code>if (!data.Equals(null))
              {
                  returnBool = true;
              }
  </code></pre>
  
  <p>but even then its giving the same object reference exception, Please help me to resolve it. 
  Thanks</p>