ASP.NET w/ C# SortedList
How do I create a SortedList that holds multiple variab开发者_如何转开发les? I want to keep multiple instances of (date, height, weight).
You need to create a class that contains the fields you want to store.
class MyVariables {
DateTime BirthDate { get; set; }
double Height { get; set; }
double Weight { get; set; }
}
and then use that in your sorted list
var list = new SortedList<string, MyVariables>();
You can create a list of your object.
public class MyItem
{
public decimal Weight {get;set;}
public decimal Height {get;set;}
public DateTime TheDate {get;set;}
}
List<MyItem> myItems = new List<MyItems>();
var mySortedList = myItems.OrderBy(p => p.Weight);
Then you can sort it with linq perhaps.
精彩评论