Here is the sample i need to form. I tried hash set it is showing as key and value but i need my output to be in the below format.
[{
"data": "Name"
},
{
"data": "Description"
}]
My sample code:
var items = new List<KeyValuePair<string, string>>();
foreach (DataColumn col in dt.Columns)
{
if (col.ColumnName !="DataType")
{
items.Add(new KeyValuePair<string, string>("data",
col.ColumnName));
}
}
var lookup = items.ToLookup(kvp => kvp.Key, kvp => kvp.Value);
When i try to add dictionary it throws me error saying key has already been added. Any guide to learn dictionary concepts in c#
Thanks