And var o = new object();, then there is one difference, former is assignable only to another similar anonymous object, while latter being object, it can be assigned to anything. If the new() generic constraint is applied, as in this example, that allows the class or method (the authenticationbase<t> class in this case) to call new t() To construct a new instance of the specified type There is no other way, short of reflection (this includes using system.activator, to construct a new object of a generic type. According to this reference for operator new Global dynamic storage operator functions are special in the standard library
All three versions of operator new are declared in the global namespac. A new expression is the whole phrase that begins with new So what do you call just the new part of it String array = new string[10]{} //the line you mentioned above was wrong because you are defining an array of length 10 ([10]), then defining an array of length 0 ({}), and trying to set them to the same array reference (array) in one statement. The introduction documents dedicate many paragraphs to explaining the difference between new() and make(), but in practice, you can create objects within local scope and return them
The context was as follows I was playing around with a custom controller class for all controllers to derive from, with standardised methods So in context, i needed to create a new instance of the object of the controller type So at time of writing, it was something like: In the specific case of throw, throw new() is a shorthand for throw new exception() As you can see, there are quite a few places where it can be used (whenever the type to be created can be inferred) to make code shorter
The place where i like it the most is for fields/properties I want to initialise an array in the format that uses commas to separate the elements surrounded in curly braces e.g However, i need to use the new operator to
WATCH