I am trying to create a string composed of a key followed by its value, such that the string looks something like:
key;value,key;value,key;value
So far I have tried to use concat:
var originalKeyValues = entity.ChangeTracker.OriginalValues.Keys.Concat(
entity.ChangeTracker.OriginalValues.Values).ToString();
...but this doesn't seem to produce what I want.
Both Keys
and Values
are Dictionary<string, object>
string result=list.Select(w=>w.Key+";"+w.Value).Aggregate((c,n)=>c+","+n);
I would do like this:
var x = new Dictionary<string, string> { { "key", "value" }, { "key2", "value2" } };
Console.WriteLine(
String.Join(",", x.Select(d => String.Format("{0};{1}", d.Key, d.Value)))
);
From the dictionary select a enumerable of string then join the list by ,
.
Output: key;value,key2;value2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With