How do I create and access a new instance of an Anonymous Class passed as a parameter in C#?

后端 未结 4 387
悲&欢浪女
悲&欢浪女 2020-12-14 12:00

I have created a function that takes a SQL command and produces output that can then be used to fill a List of class instances. The code works great. I\'ve included a slig

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 12:43

    Question #2:

    I don't really know, but I would tend to use Activator.CreateObject() instead of FormatterServices.GetUninitializedObject(), because your object might not be created properly. GetUninitializedObject() won't run a default constructor like CreateObject() will, and you don't necessarily know what's in the black box of T...

提交回复
热议问题