Javascript “var obj = new Object” Equivalent in C#

前端 未结 4 1875
别跟我提以往
别跟我提以往 2021-02-07 10:49

Is there an easy way to create and Object and set properties in C# like you can in Javascript.

Example Javascript:

var obj = new Object;

obj.value = 123         


        
4条回答
  •  长情又很酷
    2021-02-07 11:03

    The way to do this is you use C# 4.0 Dynamic types like Expando Object... see this topic:

    How to create a class dynamically

提交回复
热议问题