Delegate.Clone 方法

定义

创建委托的浅表副本。Creates a shallow copy of the delegate.

public:
 virtual System::Object ^ Clone();
public virtual object Clone ();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Overridable Function Clone () As Object

返回

委托的浅表副本。A shallow copy of the delegate.

实现

注解

克隆与原始委托具有Type相同的目标、方法和调用列表。The clone has the same Type, target, method, and invocation list as the original delegate.

浅表复制创建与原始对象具有相同类型的新实例,然后复制原始对象的非静态字段。A shallow copy creates a new instance of the same type as the original object, and then copies the nonstatic fields of the original object. 如果该字段是值类型,则执行字段的逐位副本。If the field is a value type, a bit-by-bit copy of the field is performed. 如果该字段是引用类型,则会复制引用,但不会复制引用的对象;因此,原始对象中的引用和克隆点中对同一对象的引用。If the field is a reference type, the reference is copied but the referred object is not; therefore, the reference in the original object and the reference in the clone point to the same object. 相反,对象的深层副本会复制对象中的字段直接或间接引用的所有内容。In contrast, a deep copy of an object duplicates everything directly or indirectly referenced by the fields in the object.

安全性

ReflectionPermission
当通过诸如InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])等机制后期绑定调用时。when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). 关联的枚举:MemberAccessAssociated enumeration: MemberAccess

适用于