tailieunhanh - C# 2005 Programmer’s Reference - chapter 17
Tham khảo tài liệu 'c# 2005 programmer’s reference - chapter 17', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 17 With an instance of a delegate and an appropriate set of arguments it is possible to invoke all the instance methods of the delegate. Delegate Declarations A delegate declaration is a type declaration that allows the declaration of a new delegate type delegate-declaration attributesopt delegate-modifiersopt delegate return-type identifier type- parameter-listopt formal-parameter-listopt type-parameter-constraints-clausesopt delegate-modifiers delegate-modifier delegate-modifiers delegate-modifier delegate-modifier new public protected internal private You should not have multiple instances of the same delegate modifier in a delegate declaration. If you allow this to happen you will be reminded to correct this oversight by the compile-time error that will be generated. Note that you can only use the new modifier on delegates that have been declared within another type. When you do this the delegate will hide all inherited members by the same name. Modifiers Four modifiers control the accessibility of the delegate type Public This declares that access is not limited in any way. Private Here access is limited to the containing type. Protected Here access is limited to the containing class or types derived from the containing class. Internal Access is limited to the classes defined in the same assembly as the delegate. Depending on the context of the delegate declaration some of these modifiers might not be allowed. The formal-parameter-list is optional. This specifies the parameters of the delegate while return-type is used to indicate the delegate s return type. In other words the signatures of the functions assigned to the delegates must be identical. 222 Delegates The method and delegate type are consistent if and only if the following is true For each of the parameter methods If the parameter has no out or ref modifier the corresponding parameter has no out or ref modifier either. Also there must exist an identity conversion or implicit reference .
đang nạp các trang xem trước