MyClass.cs
public class MyClass
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string path;
public string Path
{
get { return path; }
set { path= value; }
}
}
When I return a List of Type MyClass, I would like to have, only the NAME Attribute.. Not the whole object.. How I can achieve this?
Something like:
List<MyClass> myClasses = new List<MyClass>();
return myClasses["Name"]; //<--- Only the Name
You could use Linq to only return the name but you will now have a
List<string>:Alternatively you could create a new list of
MyClassfrom your original and only populate the name attibute: