I was asked recently, why I always do
gcnew T() when
gcnew T produces the exact same MSIL. Here’s why. In standard C++,
new T and
new T() are not the same. The latter version zeroes out the memory before calling the constructor, so if you haven’t initialized a member variable, it’s zero initialized by default. To be safe, I always did
new T() even though it incurred some extra lines of code. To be consistent in syntax, I chose to do the same with
gcnew too, even though for both cases, the CLR zeroes out the memory before invoking a call to the constructor.
[MOD]Just a note to add that the difference is applicable only to POD types. See my comment on this.[/MOD]