I'm looking to have a error raise to prevent a build if there are duplicate keys in my static Dictionary.
My current Dictionary below
public static readonly Dictionary<string, string> Fruits = new Dictionary<string, string>
{
{"Sobeys", "Apples"},
{"NoFrills", "Oranges"}
}
But lets say someone accidentally changes Sobeys to be Nofrills, I would like a compiler error to be raised to prevent anything to be done until that duplicate key is resolved. May I ask is that possible? If so how abouts would I do that?
public static readonly Dictionary<string, string> Fruits = new Dictionary<string, string>
{
{"NoFrills", "Apples"},
{"NoFrills", "Oranges"}
}