我喜欢语法:
Something something = new Something
{
Property1 = "property1",
Property2 = "property2"
}
但在当前项目中,我看到以下内容:
Something something = new Something();
something["Property1"] = "property1";
something["Property2"] = "property2";
我想知道是否有办法重构后者以某种方式接受后者的语法。我试图看看intellisense会提出什么建议但是没有更聪明。建议?
答案 0 :(得分:0)
如果某事是字典那么
Something something = new Something()
{
{"Property1", "property1"},
{"Property2", "property2"}
}