有一个代码:
public class Program
{
public static void Main()
{
Person p = new Person{ Name = "Best", LastName="User"};
Person p1 = new Person{ Name = "Best1", LastName="User1"};
SortedList mySL = new SortedList();
mySL.Add("2", p);
mySL.Add("1", p1);
for(int i =0; i < mySL.Count; i++)
{
Console.WriteLine("\t{0}:\t{1}", mySL.GetKey(i), mySL.GetByIndex(i));
}
}
}
public class Person
{
public string Name {get;set;}
public string LastName {get;set;}
}
这将返回:
1: ConsoleApp.Person
2: ConsoleApp.Person
是否可以在排序表中获取属性Name
?