1.词汇
- delegate instance 委托实例
- signature 签名
2.例句
-
Writing a method is that does what you want and has the same signature as the delegate type you’re using. The idea is to make sure that when you try to invoke a delegate instance, the parameters you use will all match up, and you’ll be able to use the return value (if any) in the way you expect—just like a normal method call.
现在我们要写一个方法,它能做我们想要做的任何事情,并和委托类型具有相同的签名。基本的的思路是,要确保在调用一个委托实例时,使用的参数都能匹配上,而且可以普通方法调用一样返回值(如果有的话)。
-
void PrintString(string x) method has everything right, so you can use it to create a delegate instance.
void PrintString(string x) 方法参数与返回类型都匹配,所以可以作为StringProcess的实例。
-
void PrintInteger(int x) method has one parameter, but it’s not string, so it’s incompatible with StringProcessor.
void PrintInteger(int x) 方法中有参数,但是不是字符串型的,所以不能作为StringProcessor的实例。
-
void PrintTwoStrings(string x, string y) method has the correct first parameter type, but it has another parameter as well, so it’s still incompatible.
void PrintTwoStrings(string x, string y) 方法第一个参数是正确的,但是参数数目对应不上,所以也不适合。
-
void PrintObject(object x) method is interesting,you could call the PrintObject method with the same arguments, because string derives from object. It would make sense to be able to use it for an instance of StringProcessor, but in C# 1 the delegate must have exactly the same parameter types. C# 2 changes this situation.
void PrintObject(object x) 方法比较有趣,由于string派生自object,所以该方法有着相同的参数类型。把其作为StringProcessor的实例是没有问题的,但是在C# 1是不可以的,必须是相同的类型,C#2改变了这种情况。