I'm using a WEB API to receive a request from a Client application to save Contact Information, and I need to send an Error Message only if the data has an error; otherwise nothing TODO
Earlier I Used a Dictionary<string, string>
For Example:
Dictionary<string, string> error = new Dictionary<string, string>
{
    {"SaveContactMethod_1", "FirstName Invalid"},
    {"SaveContactMethod_2", "LastName Invalid"},
    {"SaveContactMethod_3", "MiddleName Invalid"},
}
the respective JSON Object is
{
    "error" : {
        "SaveContactMethod_1":"FirstName Invalid",
        "SaveContactMethod_2":"LastName Invalid",
        "SaveContactMethod_3":"MiddleName Invalid"
    }
}
But I need an UNIQUE Key (i.e., Duplicate Key), So I changed the Dictionary<string, string> to List<KeyValuePair<string, string>>
List<KeyValuePair<string, string>> error = new List<KeyValuePair<string, string>>
{
    new KeyValuePair<string, string>("SaveContactMethod", "FirstName Invalid"),
    new KeyValuePair<string, string>("SaveContactMethod", "LastName Invalid"),
    new KeyValuePair<string, string>("SaveContactMethod", "MiddleName Invalid"),
}
the respective JSON Object is
{
    "error" : [
        { "key":"SaveContactMethod", "value":"FirstName Invalid" },
        { "key":"SaveContactMethod", "value":"LastName Invalid" },
        { "key":"SaveContactMethod", "value":"MiddleName Invalid" }
    ]
}
My Requirement: I need to add a Duplicate Key and I need the Json Output like a Dictionary.
Expected Output: JSON
{
    "error" : {
        "SaveContactMethod":"FirstName Invalid",
        "SaveContactMethod":"LastName Invalid",
        "SaveContactMethod":"MiddleName Invalid"
    }
}
 
     
     
     
    