I'm currently using a List<> with a class that contains a value Weight. As an example:
In my Main class, I'm simply doing aCode:public class Nodes { public Nodes() { // some stuff } private double m_weight; public double Weight { get { return this.m_distance; } set { m_distance = value; } } }
At this point how would I use LINQ to get the lowest, second lowest, and highest "Nodes" in Population? I read about doing something, such asCode:List<Nodes> Population = new List<Nodes>(); // some stuff Nodes LowestWeight = new Nodes(); Nodes SecondLowestWeight = new Nodes(); Nodes HighestWeight = new Nodes(); // some more stuff
but how can I get the Second Lowest? or is that syntax even correct? Any help is appreciated.Code:LowestWeight = Population.Min(); HighestWeight = Population.Max();




Reply With Quote