Created
May 28, 2021 15:14
-
-
Save guitarrapc/a78611cb2cad0be588695c895f49cc6a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace Sample | |
{ | |
public class Class | |
{ | |
public void M() | |
{ | |
var dic1 = new Dictionary<string, string>() | |
{ | |
// C# 3.0~ | |
{ "foo", "bar"}, | |
}; | |
var dic2 = new Dictionary<string, string>() | |
{ | |
// C# 6.0~ | |
["foo"] = "bar", | |
}; | |
// target typed new (C# 9.0 ~) | |
Dictionary<string, string> dic3 = new() | |
{ | |
{ "foo", "bar" }, | |
}; | |
Dictionary<string, string> dic4 = new () | |
{ | |
["foo"] = "bar", | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment