Create Class dynamically at runtime

后端 未结 4 1013
陌清茗
陌清茗 2020-12-30 15:51

I have a method like this: (this is a generic method, and DYNAMIC_CLASS_TYPE will be changed in situation to other situation)

Dim res = f.MyMeth         


        
4条回答
  •  孤城傲影
    2020-12-30 16:08

    This line:

    Dim field As FieldBuilder = myType.DefineField("_" + o.Key, GetType(Integer), FieldAttributes.[Private])
    

    must to be replaced with this:

    Dim field As FieldBuilder = myType.DefineField("_" + o.Key, o.Value, FieldAttributes.[Private])
    

提交回复
热议问题