我想在循环中选择每个用户的姓氏并将其显示在文本块中,但我得到了这个:System.Linq.Enumerable+WhereSelectListIterator2[PhoneApp1.ServiceREference1.Point,System.String]
。我该如何纠正?
我的WP代码是:
foreach (ServiceReference1.Point o in someList)
{
var text = new TextBlock
{
Text = someList.Select(x => x.surnm).ToString(),
Foreground = new SolidColorBrush(Colors.Orange),
};
}
答案 0 :(得分:4)
您已经在循环中并且具有对当前对象的引用,因此我认为没有理由进行LINQ查询。这应该有用(假设ServiceReference1.Point
有一个surnm
):
foreach (ServiceReference1.Point o in someList)
{
var text = new TextBlock
{
Text = o.surnm.ToString(),
Foreground = new SolidColorBrush(Colors.Orange),
};
}
答案 1 :(得分:0)
使用string.Join
Text = string.Join(Environment.NewLine, someList.Select(x => x.surnme)),