Class

ConstructorInfo


Description

Contains information about the constructors for a class via the Introspection system.

Properties

Name

Type

Read-Only

Shared

IsPrivate

Boolean

IsProtected

Boolean

IsPublic

Boolean

Name

String

Methods

Name

Parameters

Returns

Shared

GetAttributes

AttributeInfo()

GetParameters

ParameterInfo()

Invoke

Optional params() As Variant

Variant

Property descriptions


ConstructorInfo.IsPrivate

IsPrivate As Boolean

If True, the item has Private scope.

This property is read-only.

The following example checks the IsPrivate property before taking an action.

Var d As DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  If prop.IsPrivate Then
    ' take an action here..
  End If
Next

ConstructorInfo.IsProtected

IsProtected As Boolean

Is True, the item has Protected scope.

This property is read-only.

Var d As DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  If prop.IsProtected Then
    ' take an action here..
  End If
Next

ConstructorInfo.IsPublic

IsPublic As Boolean

If True, the item has Public scope.

This property is read-only.

This example checks the IsPublic property before taking an action.

Var d As DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  If prop.IsPublic Then
    ' take an action here..
  End If
Next

ConstructorInfo.Name

Name As String

The name of the item. This is only the class name. To get the full namespace path, use FullName instead.

This property is read-only.

This code gets the list of properties for the passed type instance.

Var d As DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  ListBox1.AddRow(prop.Name)
Next

Method descriptions


ConstructorInfo.GetAttributes

GetAttributes As AttributeInfo()

Returns an array of AttributeInfo objects.

The following gets the attributes of window1.

Var myAttributes() As Introspection.AttributeInfo = Introspection.GetType(Window1).GetAttributes

ConstructorInfo.GetParameters

GetParameters As ParameterInfo()

Returns an array of ParameterInfo items. Use GetParameters to obtain datatype information on the constructor's parameters.


ConstructorInfo.Invoke

Invoke(Optional params() As Variant) As Variant

Invokes the constructor. Pass the optional array of variants for the constructor's parameter values, if any. You will get an OutOfBoundsException if the number of parameters does not match or an IllegalCastException if the types do not match.

Sample code

This code uses the Invoke method to call the FolderItem constructor that takes no parameters:

Var ti As Introspection.TypeInfo = GetTypeInfo(FolderItem)
Var ci() As Introspection.ConstructorInfo = ti.GetConstructors

Var f As FolderItem
f = ci(0).Invoke

Compatibility

All project types on all supported operating systems.