fork(1) download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string str = "someId=00000-000-0000-000000;someotherId=123456789;someIdentifier=3030;";
  9. var idLookup = str.Split(new[]{';'}, StringSplitOptions.RemoveEmptyEntries)
  10. .Select(token => new {
  11. keyvalues=token.Split(new[]{'='}, StringSplitOptions.RemoveEmptyEntries)
  12. })
  13. .ToLookup(x => x.keyvalues.First(), x => x.keyvalues.Last());
  14.  
  15. // now you can lookup a key to get it's value similar to a Dictionary but with duplicates allowed
  16. string someotherId = idLookup["someotherId"].First();
  17. Console.Write("someotherId: " + someotherId);
  18. }
  19. }
Success #stdin #stdout 0.04s 34128KB
stdin
Standard input is empty
stdout
someotherId: 123456789