配列(コレクション)初期化の記述
書き方をよく忘れるのでメモ。
C# 3.0から、ListやDictionaryの初期代入を比較的簡単に記述できるようになっています。
■List
var list = new List<string>(){ "test0", "test1", "test2", "test3", };
■Dictionary
var dic = new Dictionary<string, string>(){ {"test0", "message0"}, {"test1", "message1"}, {"test2", "message2"}, {"test3", "message3"}, };
単純な配列などは以下のとおり
var strList = string[]{ "test0", "test1", "test2", "test3", };