consider:
this.listBox1.Items.Clear();
Type t = this.GetType();
PropertyInfo[] p = t.GetProperties();
IEnumerable<PropertyInfo> names = p.Where(cust => cust.Name.StartsWith("S"));
foreach (PropertyInfo s in names)
{
this.listBox1.Items.Add(s.Name);
}
here we are returning a property info object and there we need not the select
but here:
this.listBox1.Items.Clear();
Type t = this.GetType();
PropertyInfo[] p = t.GetProperties();
IEnumerable<string> names = p.Where(cust => cust.Name.StartsWith("S")).Select(cust => cust.Name); //from nms in p select nms.Name;
foreach (string s in names)
{
this.listBox1.Items.Add(s);
}
we need the select because we are changing the projected type
No comments:
Post a Comment