Sunday, 25 August 2013

C# string to Dictionary with LINQ

C# string to Dictionary with LINQ

Say I have a string like this:
string test = "A1:B1:C1, A2:B2:C2, A3:B3:C3"
How can I use LINQ to split it up and store it in a Dictionary<string,
List<string>>
as follows:
Key: A1 (string)
Value: B1 and C1 (List<string>)
Key: A2 (string)
Value: B2 and C2 (List<string>)
Key: A3 (string)
Value: B3 and C3 (List<string>)


Thanks guys.

No comments:

Post a Comment