Instance of Object Creation Operator

The New operator is used to create new instances of classes and value types. There are three forms of New operators:

Object Creation Operator

An object creation operator is used to create a new instance of a class type or a value type.

object-creation-expression:

New   type   constructor-specifieropt ( argument-listopt )

constructor-specifier:

.   identifier

The expression should include the type of created object, optional constructor name and argument list. If the constructor name is not given in the expression, the compiler determines a constructor, the number and the type of arguments in which match the number and type of expressions passed in the argument list. A compile error occurs if such a constructor cannot be identified.

Array Instance Creation Operator

An array instance creation operator is used to create a new instance of an array type.

array-creation-expression:

New   non-array-type   [   expression-list   ]   array-creation-expression-initializeropt

New  (   array-type   ,   array-initializer   )

array-creation-expression-initializer:

=   array-initializer

Delegate Instance Creation Operator

A delegate instance creation operator is used to create a new instance of a delegate type.

delegate-creation-expression:

New   delegate-type   (   expression   )

The argument of a delegate instance creation operator must be either a method group or a value of a delegate type. If the argument is a method group, it identifies the method and, for instance methods, the object for which to create a delegate. If the argument is a value of a delegate type, it identifies a delegate instance of which to create a copy.

The compile-time processing of a delegate instance creation operator of the New D(E) form, where D is a delegate type and E is an expression, consists of the following steps:

See also:

Primary Expressions