title: How to check if string is null in c#.net
body: <p>I am reading text file in c#.net 
  at the end one line is completely null but in foreach c# can not detect null string so It gets error </p>
  
  <pre><code>string[] lines = System.IO.File.ReadAllLines(dir);
  List&lt;KeyValuePair&lt;int, DateTime&gt;&gt; items = new List&lt;KeyValuePair&lt;int, DateTime&gt;&gt;();
  List&lt;KeyValuePair&lt;int, DateTime&gt;&gt; lst = new List&lt;KeyValuePair&lt;int, DateTime&gt;&gt;();
  foreach (string line in lines)
  {
      if (line!=string.Empty)
      {
          l = line.Split('\t');
          l[0] = l[0].Trim();
          PersianCalendar persCal = new PersianCalendar();
          SqlConnection sqlconn = new SqlConnection(DBsetting.Connstring);
          SqlCommand sqlda = new SqlCommand("InsertReadd", sqlconn);
          sqlda.CommandType = CommandType.StoredProcedure;
          sqlda.Parameters.AddWithValue("@date", l[1]);
          sqlda.Parameters.AddWithValue("@IDp", l[0]);
          sqlda.Parameters.AddWithValue("@day", GetDayOfWeek(GetPerDate(l[1])));
          sqlda.Parameters.AddWithValue("@nobatkari", "");
          sqlda.Connection.Open();
          sqlda.ExecuteNonQuery();
          sqlda.Connection.Close();
      }
  }
  RefGrid();
  </code></pre>