In the below piece of code, is there a way to not need a foreach? All that needs to happen is that if a single of the split parts exceeds a length, i can set it as invalid.
My colleage is sure he used a one line piece of code for this but google left me with no evidence of this.
else if (lineSplit[11].Length > Constant.EstimatedBirthdatesofChildren)
{
var estimatedBirthdatesofChildren = lineSplit[11].Split('~');
foreach (String estimatedBirthdatesofChild in estimatedBirthdatesofChildren)
{
if (estimatedBirthdatesofChild.Length > Constant.EstimatedBirthdatesofChild) valid = false;
}
}
Oops, you mean you need the first token having more than expected length? your question is not clear, but if yes, you can write