开发者

ASP.NET w/ C# SortedList

开发者 https://www.devze.com 2023-02-13 12:15 出处:网络
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

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

精彩评论

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