Hey there, I have this foreach loop that doesnt work 100%. Basically I am outputting a string. My problem is I dont want sb.Append(","); to be added the last record in the loop. IS there an easy way using linq to solve this?
sb.Append("Readings:[");
foreach (var reading in lake.Reading)
{
sb.Append("[");
sb.Append("\"");
sb.Append(reading.DateTime.ToString("dd-MMM-yy"));
sb.Append("\"");
sb.Append(",");
sb.Append(reading.Level);
sb.Append("]");
//only insert this line if its the not the last record sb.Append(",");
}
sb.Append("]");