When you use generic methods, it "fills in the blanks" from the type of the collection - so the properties and methods you can use on each object depends on the type of the collection.
So a collection of Point object can use Point propertuies:
List<Point> points = GetPoints();
List<Point> leftColumn = points.Where(p => p.X <= 10).ToList();
But a collection of strings would let you use string properties:
List<string> strings = GetStrings();
List<string> shortStrings = strings.Where(s => s.Length <= 10).ToList();
Whatever your collection is declared as determines what properties and methods you can use inside your class, not what items in the collection may be. So if you use a base class:
List<object> strings = GetStrings();
List<string> shortStrings = strings.Where(s => s.Length <= 10).ToList();
You will get an error because
Length
is not a property of the
object
class, even if all the objects in the collection are strings, and have a Length - the system doesn't "know" that all the objects in the class will always be strings:
List<object> strings = new List<object>();
strings.Add("Hello!");
strings.Add(666);
strigns.Add(new Point(12, 42));
List<string> shortStrings = strings.Where(s => s.Length <= 10).ToList();
So look to what
setNames
is declared as - that controls what properties you can use.