Export (0) Print
Expand All

DynamicObject.TryCreateInstance Method

Provides the implementation for operations that initialize a new instance of a dynamic object. This method is not intended for use in C# or Visual Basic.

Namespace:  System.Dynamic
Assembly:  System.Core (in System.Core.dll)

public virtual bool TryCreateInstance(
	CreateInstanceBinder binder,
	Object[] args,
	out Object result
)

Parameters

binder
Type: System.Dynamic.CreateInstanceBinder
Provides information about the initialization operation.
args
Type: System.Object[]
The arguments that are passed to the object during initialization. For example, for the new SampleType(100) operation, where SampleType is the type derived from the DynamicObject class, args[0] is equal to 100.
result
Type: System.Object%
The result of the initialization.

Return Value

Type: System.Boolean
true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)

Classes derived from the DynamicObject class can override this method to specify how a new instance of the dynamic object should be initialized. When the method is not overridden, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)

C# and Visual Basic compilers never emit code to use this method because they do not support first-class types. This method is intended for languages that support the initialization of dynamic objects by using syntax like dynamic new.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2015 Microsoft