MethodInfo.CreateDelegate Method

Definition

Creates a delegate from this method.

Overloads

CreateDelegate(Type)

Creates a delegate of the specified type from this method.

CreateDelegate(Type, Object)

Creates a delegate of the specified type with the specified target from this method.

CreateDelegate<T>()

Creates a delegate of type T from this method.

CreateDelegate<T>(Object)

Creates a delegate of type T with the specified target from this method.

CreateDelegate(Type)

Source:
MethodInfo.cs
Source:
MethodInfo.cs
Source:
MethodInfo.cs

Creates a delegate of the specified type from this method.

C#
public virtual Delegate CreateDelegate(Type delegateType);

Parameters

delegateType
Type

The type of the delegate to create.

Returns

The delegate for this method.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

CreateDelegate(Type, Object)

Source:
MethodInfo.cs
Source:
MethodInfo.cs
Source:
MethodInfo.cs

Creates a delegate of the specified type with the specified target from this method.

C#
public virtual Delegate CreateDelegate(Type delegateType, object target);
C#
public virtual Delegate CreateDelegate(Type delegateType, object? target);

Parameters

delegateType
Type

The type of the delegate to create.

target
Object

The object targeted by the delegate.

Returns

The delegate for this method.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

CreateDelegate<T>()

Source:
MethodInfo.cs
Source:
MethodInfo.cs
Source:
MethodInfo.cs

Creates a delegate of type T from this method.

C#
public T CreateDelegate<T>() where T : Delegate;

Type Parameters

T

The type of the delegate to create.

Returns

T

The delegate for this method.

Applies to

.NET 9 and other versions
Product Versions
.NET 5, 6, 7, 8, 9

CreateDelegate<T>(Object)

Source:
MethodInfo.cs
Source:
MethodInfo.cs
Source:
MethodInfo.cs

Creates a delegate of type T with the specified target from this method.

C#
public T CreateDelegate<T>(object? target) where T : Delegate;

Type Parameters

T

The type of the delegate to create.

Parameters

target
Object

The object targeted by the delegate.

Returns

T

The delegate for this method.

Applies to

.NET 9 and other versions
Product Versions
.NET 5, 6, 7, 8, 9