substring with linq?
c#, linq, string
Solution
LINQ to objects for this scenario? You can do a select as in this:
from w in words
select new
{
Word = (w.Length > 5) ? w.Substring(0, 5) : w
};
Essentially, ?: gets you around this issue.
Problem
I've got collection of words, and i wanna create collection from this collection limited to 5 chars Input: ``` Car Collection Limited stackoverflow ``` Output: ``` car colle limit stack ``` word.Substring(0,5) throws exception (length) word.Take(10) is not good idea, too... Any good ideas ??