My Blog

Convertire un Dictionary a String in un passo

by lupok on giovedì 31 gennaio 2013 10:27
String.Join(", ", Dictionary.Select(kv => String.Format("{0} = {1}", kv.Key, kv.Value)));
e per convertire da String a Dictionary:
Dictionary<String, Int32> dictionary = buffer.Split(',').Select(s => s.Split('='))
   .ToDictionary(key => key[0].Trim(), value => Int32.Parse(value[1].Trim()));

Blogs Parent Separator My Blog
Author
lupok

My Blog

Tags