Can delegates be private? If not, what’s the reason behind this other than the normal restrictions caused by it being private?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Delegates have the same restrictions as any type with regards to visibility. So you cannot have a private delegate at the top level.
This generates a compiler error:
But like a class, you can declare a delegate private when it resides within another class.
The reason basically goes back to the definition of what
privateis in C#: