I have class with 5 fields.
public class Test
{
public string name;
public string description;
public int int1;
public int int2;
public int int3;
}
In one of my function I have List<Test> list which has 10 items. Here I want SortedList<string,string> for two properties name & description.
I know, I can achieve this using for each but I want to know How can I do this using LINQ?
The answer from @HugoRune is quite exhaustive, but because you said you want to use Linq, I’d suggest to add an extension method in your scope to help you with your goal:
this way your SortedList creation is composable in Linq computations: