C#英语笔记Day 45

1.词汇

  • delegate instance 委托实例
  • Static Method 静态方法
  • Instance Method 实例方法

2.例句

  • Now that you have a delegate type and a method with the right signature, you can create an instance of that delegate type,specifying that this method be executed when the delegate instance is invoked.

    现在我们已经有了一个委托类型和一个正确的签名方法,那么我们可以接着创建一个委托实例了,并指定委托实例被调用时,要执行的方法。

  • The exact form of the expression used to create the delegate instance depends on whether the action uses an instance method or a static method. Suppose PrintString is a static method in a type called StaticMethods and an instance method in a type called InstanceMethods.

    至于具体用什么形式来创建委托实例,这取决于方法是实例方法还是静态方法。假设PrintString是一个StaticMethods类的静态方法,在InstanceMethods类型中是一个实例方法.

3.代码

StringProcessor proc1, proc2;
proc1 = new StringProcessor(StaticMethods.PrintString);
InstanceMethods instance = new InstanceMethods();
proc2 = new StringProcessor(instance.PrintString);
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。