Sdílet prostřednictvím


ModuleBuilder.DefineType Method (String, TypeAttributes, Type, array<Type[])

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Defines a type with the specified type name, attributes, base type, and implemented interfaces in this module.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
<ComVisibleAttribute(True)> _
Public Function DefineType ( _
    name As String, _
    attr As TypeAttributes, _
    parent As Type, _
    interfaces As Type() _
) As TypeBuilder
[SecuritySafeCriticalAttribute]
[ComVisibleAttribute(true)]
public TypeBuilder DefineType(
    string name,
    TypeAttributes attr,
    Type parent,
    Type[] interfaces
)

Parameters

  • name
    Type: System.String
    The full name of the type, including the namespace. name cannot contain embedded nulls.
  • parent
    Type: System.Type
    The type that the defined type extends.
  • interfaces
    Type: array<System.Type[]
    The list of interfaces that the type implements.

Return Value

Type: System.Reflection.Emit.TypeBuilder
A type with the specified characteristics.

Exceptions

Exception Condition
ArgumentException

A type with the given name exists in the parent assembly of this module.

-or-

Nested type attributes are set on a type that is not nested.

ArgumentNullException

name is nulla null reference (Nothing in Visual Basic).

Remarks

Type names must be unique within an assembly.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.