【发布时间】:2012-06-11 09:33:22
【问题描述】:
我有这个 IEnumerable 类型的 Question.. 类 Question 具有属性 Question(string) 和 Id(int)
我想要做的是,如果 IEnumerable 中任何对象的问题的长度 > 25 然后“子串”它并添加“...”
所以我的想法是这样的:
ienumQuestions.Where(e=>e.Question.Length > 25).Change(e.Question=>e.Question.Substring(25)+"...");
现在我不确定该语法是否 100% 正确,但我希望你明白这一点..
有没有办法做到这一点?..我真的不想为此创建一个循环..因为我根本不喜欢循环:)
提前致谢!
【问题讨论】:
-
你不喜欢循环吗?您认为 IEnumerable 是如何实现的?
标签: c# lambda ienumerable