Can a class property/field be of anonymous type in C# 4.0?

后端 未结 7 1764
后悔当初
后悔当初 2021-01-18 02:53

As in:

public class MyClass {

  private static var MyProp = new {item1 = \"a\", item2 = \"b\"};

}

Note: The above doesn\'t compile nor wo

相关标签:
7条回答
  • 2021-01-18 03:46

    No, any member should be a strongly typed.

    You might go for dynamic type to give your member a chance to be evaluated at runtime though.

    Edit : Members should be Explicitly Typed.

    0 讨论(0)
提交回复
热议问题