开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜