Well you could get all of
if (!string.IsNullOrEmpty(s1))
x1 = TimeSpan.Parse(s1= (s1 == "24:00:00") ? "23:59:59" : s1);
as a single line using the ternary operator again.
x1 = (!string.IsNullOrEmpty(s1)) ? TimeSpan.Parse(s1 = (s1 == "24:00:00") ? "23:59:59" : s1) : TimeSpan.Zero
But personally I would write a little helper function to do that data adjustment for you. E.g.
private TimeSpan AdjustTime(int row, string colName)
{
string s1 = dataGridView1.Rows[row].Cells[colName].Value.ToString();
return ((!string.IsNullOrEmpty(s1)) ? TimeSpan.Parse(s1 = (s1 == "24:00:00") ? "23:59:59" : s1) : TimeSpan.Zero);
}
Then you would use it like this
TimeSpan x1 = AdjustTime(i, "MrnngEnt");
TimeSpan x2 = AdjustTime(i, "NextColumn");