私は他の誰かのコードを維持していて、彼らはメソッドにこのセクションを持っています:
object ReportCriteriaInstance =
Activator.CreateInstance(
typeof(MyCompany.Utils.ReportStructure.ReportSearchCriteria));
//ReportCriteria is passed in as a method parameter
ReportCriteriaInstance = ReportCriteria;
ReportCriteriaInstace
でインスタンス化した後、1行で異なる値に設定されている理由がわかりませんCreateInstance()
。
それとは別に、既知の型をCreateInstance
(MyCompany.Utils.ReportStructure.ReportSearchCriteria
)に渡すので、代わりにnew()を使用しない理由はありますか?いくつかのデフォルトのパラメーターなしのコンストラクターの理由は、私が多分得られないのですか?