I recently met code in an application that does the equivalent of this:
var source = new List<string>();
source.AddRange(getSomeListData());
var index = source.Count > 10 ? source.Count - 10 : 0;
var target = new TargetObject
{
Line1 = source.Count > index ? source[index++] : string.Empty,
Line2 = source.Count > index ? source[index++] : string.Empty,
Line3 = source.Count > index ? source[index++] : string.Empty,
Line4 = source.Count > index ? source[index++] : string.Empty,
.
.
.
}
The goal is to include the last 10 elements from the source data in the output object (in our case, the last line is critical). But we do not know how many rows of data will be present - it can be only 1.
, VS2013 , index++ . , # 5, , . , , - VS / #?
( , , .)