|
97 | 97 |
|
98 | 98 | For more information on delegate binding, see the <xref:System.Delegate.CreateDelegate%28System.Type%2CSystem.Object%2CSystem.Reflection.MethodInfo%2CSystem.Boolean%29> method overload.
|
99 | 99 |
|
100 |
| -> [!NOTE] |
101 |
| -> In the .NET Framework versions 1.0 and 1.1, a delegate can represent a method only if the signature of the method exactly matches the signature specified by the delegate type. Thus, only the first and third bullets in the preceding list are supported, and the first bullet requires an exact type match. |
102 |
| - |
103 | 100 | When a delegate represents an instance method closed over its first argument (the most common case), the delegate stores a reference to the method's entry point and a reference to an object, called the target, which is of a type assignable to the type that defined the method. When a delegate represents an open instance method, it stores a reference to the method's entry point. The delegate signature must include the hidden `this` parameter in its formal parameter list; in this case, the delegate does not have a reference to a target object, and a target object must be supplied when the delegate is invoked.
|
104 | 101 |
|
105 | 102 | When a delegate represents a static method, the delegate stores a reference to the method's entry point. When a delegate represents a static method closed over its first argument, the delegate stores a reference to the method's entry point and a reference to a target object assignable to the type of the method's first argument. When the delegate is invoked, the first argument of the static method receives the target object. This first argument must be a reference type.
|
|
633 | 630 | </Parameters>
|
634 | 631 | <Docs>
|
635 | 632 | <param name="type">The <see cref="T:System.Type" /> of delegate to create.</param>
|
636 |
| - <param name="method">The <see cref="T:System.Reflection.MethodInfo" /> describing the static or instance method the delegate is to represent. Only static methods are supported in the .NET Framework version 1.0 and 1.1.</param> |
637 |
| - <summary>Creates a delegate of the specified type to represent the specified static method.</summary> |
638 |
| - <returns>A delegate of the specified type to represent the specified static method.</returns> |
| 633 | + <param name="method">The <see cref="T:System.Reflection.MethodInfo" /> describing the static or instance method the delegate is to represent.</param> |
| 634 | + <summary>Creates a delegate of the specified type to represent the specified method.</summary> |
| 635 | + <returns>A delegate of the specified type to represent the specified method.</returns> |
639 | 636 | <remarks>
|
640 | 637 | <format type="text/markdown"><![CDATA[
|
641 | 638 |
|
|
723 | 720 |
|
724 | 721 | -or-
|
725 | 722 |
|
726 |
| - <paramref name="method" /> is not a static method, and the .NET Framework version is 1.0 or 1.1. |
727 |
| - |
728 |
| - -or- |
729 |
| - |
730 | 723 | <paramref name="method" /> cannot be bound.
|
731 | 724 |
|
732 | 725 | -or-
|
|
822 | 815 | ## Compatible Parameter Types and Return Type
|
823 | 816 | The parameter types and return type of a delegate must be compatible with the parameter types and return type of the method the delegate represents; the types do not have to match exactly.
|
824 | 817 |
|
825 |
| -> [!NOTE] |
826 |
| -> In the .NET Framework version 1.0 and 1.1, the types must match exactly. |
827 |
| - |
828 | 818 | A parameter of a delegate is compatible with the corresponding parameter of a method if the type of the delegate parameter is more restrictive than the type of the method parameter, because this guarantees that an argument passed to the delegate can be passed safely to the method.
|
829 | 819 |
|
830 | 820 | Similarly, the return type of a delegate is compatible with the return type of a method if the return type of the method is more restrictive than the return type of the delegate, because this guarantees that the return value of the method can be cast safely to the return type of the delegate.
|
|
1114 | 1104 | ## Compatible Parameter Types and Return Type
|
1115 | 1105 | The parameter types and return type of a delegate must be compatible with the parameter types and return type of the method the delegate represents; the types do not have to match exactly.
|
1116 | 1106 |
|
1117 |
| -> [!NOTE] |
1118 |
| -> In the .NET Framework version 1.0 and 1.1, the types must match exactly. |
1119 |
| - |
1120 | 1107 | A parameter of a delegate is compatible with the corresponding parameter of a method if the type of the delegate parameter is more restrictive than the type of the method parameter, because this guarantees that an argument passed to the delegate can be passed safely to the method.
|
1121 | 1108 |
|
1122 | 1109 | Similarly, the return type of a delegate is compatible with the return type of a method if the return type of the method is more restrictive than the return type of the delegate, because this guarantees that the return value of the method can be cast safely to the return type of the delegate.
|
|
1404 | 1391 | ## Compatible Parameter Types and Return Type
|
1405 | 1392 | The parameter types and return type of a delegate must be compatible with the parameter types and return type of the method the delegate represents; the types do not have to match exactly.
|
1406 | 1393 |
|
1407 |
| -> [!NOTE] |
1408 |
| -> In the .NET Framework version 1.0 and 1.1 the types must match exactly. |
1409 |
| - |
1410 | 1394 | A parameter of a delegate is compatible with the corresponding parameter of a method if the type of the delegate parameter is more restrictive than the type of the method parameter, because this guarantees that an argument passed to the delegate can be passed safely to the method.
|
1411 | 1395 |
|
1412 | 1396 | Similarly, the return type of a delegate is compatible with the return type of a method if the return type of the method is more restrictive than the return type of the delegate, because this guarantees that the return value of the method can be cast safely to the return type of the delegate.
|
|
2039 | 2023 |
|
2040 | 2024 | ]]></format>
|
2041 | 2025 | </remarks>
|
2042 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private). |
2043 |
| - |
2044 |
| - -or- |
2045 |
| - |
2046 |
| - The number, order, or type of parameters listed in <paramref name="args" /> is invalid.</exception> |
2047 |
| - <exception cref="T:System.ArgumentException">The method represented by the delegate is invoked on an object or a class that does not support it.</exception> |
| 2026 | + <exception cref="T:System.Reflection.TargetParameterCountException">The <paramref name="args" /> array does not have the correct number of arguments.</exception> |
| 2027 | + <exception cref="T:System.ArgumentException">The elements of the <paramref name="args" /> array do not match the signature of the delegate.</exception> |
2048 | 2028 | <exception cref="T:System.Reflection.TargetInvocationException">The method represented by the delegate is an instance method and the target object is <see langword="null" />.
|
2049 | 2029 |
|
2050 | 2030 | -or-
|
|
2113 | 2093 |
|
2114 | 2094 | ]]></format>
|
2115 | 2095 | </remarks>
|
2116 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private). |
2117 |
| - |
2118 |
| - -or- |
2119 |
| - |
2120 |
| - The number, order, or type of parameters listed in <paramref name="args" /> is invalid.</exception> |
2121 |
| - <exception cref="T:System.ArgumentException">The method represented by the delegate is invoked on an object or a class that does not support it.</exception> |
| 2096 | + <exception cref="T:System.Reflection.TargetParameterCountException">The <paramref name="args" /> array does not have the correct number of arguments.</exception> |
| 2097 | + <exception cref="T:System.ArgumentException">The elements of the <paramref name="args" /> array do not match the signature of the delegate.</exception> |
2122 | 2098 | <exception cref="T:System.Reflection.TargetInvocationException">The method represented by the delegate is an instance method and the target object is <see langword="null" />.
|
2123 | 2099 |
|
2124 | 2100 | -or-
|
|
2193 | 2169 | ## Remarks
|
2194 | 2170 | If the two delegates are not of the same type, they are not considered equal.
|
2195 | 2171 |
|
2196 |
| -> [!IMPORTANT] |
2197 |
| -> In the .NET Framework version 1.0 and 1.1, two delegates were considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types. |
2198 |
| - |
2199 | 2172 | The methods and targets are compared for equality as follows:
|
2200 | 2173 |
|
2201 | 2174 | - If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.
|
|
2208 | 2181 |
|
2209 | 2182 | ]]></format>
|
2210 | 2183 | </remarks>
|
2211 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception> |
2212 | 2184 | <altmember cref="T:System.Object" />
|
2213 | 2185 | </Docs>
|
2214 | 2186 | </Member>
|
|
2367 | 2339 | </ReturnValue>
|
2368 | 2340 | <Parameters />
|
2369 | 2341 | <Docs>
|
2370 |
| - <summary>Gets the static method represented by the current delegate.</summary> |
2371 |
| - <returns>A <see cref="T:System.Reflection.MethodInfo" /> describing the static method represented by the current delegate.</returns> |
| 2342 | + <summary>Gets the method represented by the current delegate.</summary> |
| 2343 | + <returns>A <see cref="T:System.Reflection.MethodInfo" /> describing the method represented by the current delegate.</returns> |
2372 | 2344 | <remarks>
|
2373 | 2345 | <format type="text/markdown"><![CDATA[
|
2374 | 2346 |
|
2375 | 2347 | ## Remarks
|
2376 |
| - This method applies only if the current delegate represents a static method. |
| 2348 | + This method implements the <xref:System.Delegate.Method%2A> property. |
2377 | 2349 |
|
2378 | 2350 | ]]></format>
|
2379 | 2351 | </remarks>
|
2380 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception> |
2381 | 2352 | <altmember cref="T:System.Reflection.MethodInfo" />
|
2382 | 2353 | <altmember cref="P:System.Delegate.Method" />
|
2383 | 2354 | </Docs>
|
|
2482 | 2453 | <summary>Gets the method represented by the delegate.</summary>
|
2483 | 2454 | <value>A <see cref="T:System.Reflection.MethodInfo" /> describing the method represented by the delegate.</value>
|
2484 | 2455 | <remarks>To be added.</remarks>
|
2485 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception> |
2486 | 2456 | <altmember cref="T:System.Reflection.MethodInfo" />
|
2487 | 2457 | <altmember cref="M:System.Delegate.GetMethodImpl" />
|
2488 | 2458 | </Docs>
|
|
2549 | 2519 |
|
2550 | 2520 | If the two delegates are not of the same type, they are not considered equal.
|
2551 | 2521 |
|
2552 |
| -> [!IMPORTANT] |
2553 |
| -> In the .NET Framework version 1.0 and 1.1, two delegates were considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types. |
2554 |
| - |
2555 | 2522 | The methods and targets are compared for equality as follows:
|
2556 | 2523 |
|
2557 | 2524 | - If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.
|
|
2623 | 2590 |
|
2624 | 2591 | If the two delegates are not of the same type, they are not considered equal.
|
2625 | 2592 |
|
2626 |
| -> [!IMPORTANT] |
2627 |
| -> In the .NET Framework version 1.0 and 1.1, two delegates are considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types. |
2628 |
| - |
2629 | 2593 | The methods and targets are compared for equality as follows:
|
2630 | 2594 |
|
2631 | 2595 | - If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.
|
|
2702 | 2666 |
|
2703 | 2667 | ]]></format>
|
2704 | 2668 | </remarks>
|
2705 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception> |
2706 | 2669 | <exception cref="T:System.ArgumentException">The delegate types do not match.</exception>
|
2707 | 2670 | <altmember cref="M:System.Delegate.RemoveAll(System.Delegate,System.Delegate)" />
|
2708 | 2671 | <altmember cref="M:System.Delegate.RemoveImpl(System.Delegate)" />
|
|
2764 | 2727 |
|
2765 | 2728 | ]]></format>
|
2766 | 2729 | </remarks>
|
2767 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception> |
2768 | 2730 | <exception cref="T:System.ArgumentException">The delegate types do not match.</exception>
|
2769 | 2731 | <altmember cref="M:System.Delegate.Remove(System.Delegate,System.Delegate)" />
|
2770 | 2732 | <altmember cref="M:System.Delegate.RemoveImpl(System.Delegate)" />
|
|
2820 | 2782 |
|
2821 | 2783 | ]]></format>
|
2822 | 2784 | </remarks>
|
2823 |
| - <exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception> |
2824 | 2785 | <altmember cref="M:System.Delegate.Remove(System.Delegate,System.Delegate)" />
|
2825 | 2786 | <altmember cref="M:System.Delegate.Equals(System.Object)" />
|
2826 | 2787 | </Docs>
|
|
0 commit comments