Delegate Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new delegate.
Overloads
Delegate(Object, String) |
Initializes a delegate that invokes the specified instance method on the specified class instance. |
Delegate(Type, String) |
Initializes a delegate that invokes the specified static method from the specified class. |
Delegate(Object, String)
- Source:
- Delegate.CoreCLR.cs
- Source:
- Delegate.CoreCLR.cs
- Source:
- Delegate.CoreCLR.cs
Initializes a delegate that invokes the specified instance method on the specified class instance.
protected:
Delegate(System::Object ^ target, System::String ^ method);
protected Delegate (object target, string method);
new Delegate : obj * string -> Delegate
Protected Sub New (target As Object, method As String)
Parameters
- target
- Object
The class instance on which the delegate invokes method
.
- method
- String
The name of the instance method that the delegate represents.
Exceptions
There was an error binding to the target method.
Remarks
This constructor cannot be used in application code. To create a delegate by specifying the name of an instance method, use an overload of the CreateDelegate method that specifies a method name and a target object. For example, the CreateDelegate(Type, Object, String) method overload creates a delegate for an instance method with a specified name.
This constructor creates delegates for instance methods only. An instance method is a method that is associated with an instance of a class; a static method is a method that is associated with the class itself.
See also
Applies to
Delegate(Type, String)
- Source:
- Delegate.CoreCLR.cs
- Source:
- Delegate.CoreCLR.cs
- Source:
- Delegate.CoreCLR.cs
Initializes a delegate that invokes the specified static method from the specified class.
protected:
Delegate(Type ^ target, System::String ^ method);
protected Delegate (Type target, string method);
new Delegate : Type * string -> Delegate
Protected Sub New (target As Type, method As String)
Parameters
- method
- String
The name of the static method that the delegate represents.
Exceptions
target
is not a RuntimeType
. See Runtime Types in Reflection.
-or-
target
represents an open generic type.
Remarks
This constructor cannot be used in application code. To create a delegate by specifying the name of a static method, use an overload of the CreateDelegate method that specifies a method name but does not specify a target object. For example, the CreateDelegate(Type, Type, String) method overload creates a static delegate for a method with a specified name.
This constructor creates delegates for static methods only. An instance method is a method that is associated with an instance of a class; a static method is a method that is associated with the class itself.
See also
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기