C# language feature:
applies to
benefit
how to use
[
and ]
followed by =
followed by initial value. Seperate with ,
if repeating multiple key/value initializations.note
example:
private Dictionary<int, string> webErrors = new Dictionary<int, string>
{
[401] = "Not authorized",
[404] = "Page/Resource not found",
[500] = "Internal server error"
};
// previously initialization would be declared with and object contianing key value objects seperated by comma
private Dictionary<int, string> uglier_webErrors_initialization= new Dictionary<int, string>
{
{401 , "Not authorized" },
{404 , "Page/Resource not found" },
{500 , "Internal server error" }
};