如何使用集合初始值设定项创建新字典?

Jay*_*asa 1 c#

如果你可以在List中执行此操作

List<int> a = new List<int>() {
   2, 4, 6, 8, 10
};
Run Code Online (Sandbox Code Playgroud)

你怎么能在字典里做同样的事情?

Dictionary<int, bool> b = new Dictionary<int, bool>() {
   ?, ?, ?
};
Run Code Online (Sandbox Code Playgroud)

Jos*_*osh 8

Dictionary<int, bool> b = new Dictionary<int, bool>() {
   {1, true},{2, false},{3, true}
};
Run Code Online (Sandbox Code Playgroud)