So I am learning the basics of LINQ and I´m haveing a little trouble. How can I get the interval under entry name and exit name?? I'm having a hard time to solve this. this is the code
List<list> list = new List<list>();
station1 = new list()
{
no = 1,
interval = 0,
name = "name1",
};
station2 = new list()
{
no = 2,
interval = 1,
name = "name2",
};
station3 = new list()
{
no= 3,
interval = 2,
name = "name3",
};
station4 = new list()
{
no = 4,
interval = 1,
name = "name4",
};
station5 = new list()
{
no = 5,
interval = 1,
name = "name5",
};
for example I enter the entry station and exit station (name1, name5) I want to add those interval inside the station under name1 and name5.
so the process will be output = name2.interval = 1 + name3.interval = 2 + name4.interval = 1 ;
total interval = 4
What I tried is, which is wrong and I am stuck:
interval = list.GetRange(entry, exit);
This only gives me the interval of entry so I need to add a filter. Been trying this and that with no luck. If anyone could give me more hints or be of some assistance would be greatly appreciated
list?listboth as a name for the variable containing the list, as well as for the class defining the structure of an item. Unless you deliberately want to obfuscate your code, this is a terrible idea. Do your co-workers and your future self a big favor and rename yourclass list { ... }toclass Item { ... }.