I am looking for you to have errors to prevent assembly if there are duplicate keys in my static dictionary.
My current dictionary is below
public static readonly Dictionary<string, string> Fruits = new Dictionary<string, string> { {"Sobeys", "Apples"}, {"NoFrills", "Oranges"} }
But let's say someone accidentally swaps Sobeys for Nofrills, I would like a compiler error to be raised to prevent anything until this duplicate key is resolved. May I ask if this is possible? If so, how could I do this?
public static readonly Dictionary<string, string> Fruits = new Dictionary<string, string> { {"NoFrills", "Apples"}, {"NoFrills", "Oranges"} }
source share