これらの 2 つの行は異なることを行います。
最初のものは新しいセットを作成し、次に 2 番目のセットをそれにマージします。
2 番目のものは、2 番目のセットを指すように ds 参照を設定するため、次のようになります。
MyTypedDataSet ds1 = new MyTypedDataSet();
ds1.Merge(anotherDataSet);
//ds1 is a copy of anotherDataSet
ds1.Tables.Add("test")
//anotherDataSet does not contain the new table
MyTypedDataSet ds2 = anotherDataSet;
//ds12 actually points to anotherDataSet
ds2.Tables.Add("test");
//anotherDataSet now contains the new table
わかりました、あなたが意味したことは次のとおりであると仮定しましょう:
MyClass o1 = new MyClass();
o1.LoadFrom( /* some data */ );
//vs
MyClass o2 = new MyClass( /* some data */ );
次に、前者はデータを入力する前に空のオブジェクトを作成するため、後者の方が優れています。
ただし、空のクラスの初期化に高いコストがかかるか、何度も繰り返されない限り、違いはそれほど重要ではありません。