Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Classes in the .NET Framework > Anatomy of a Method

Anatomy of a Method

image

The syntax for a method declaration is almost identical to the syntax for declaring a variable, class or property:

image

Make a Note

image

There are a few constraints on the access modifier of an instance method. First, it cannot be less restrictive than the type that defines it, which makes sense...how would you call MyClass.X() if you can’t see MyClass? And second, for pretty much the same reason, it cannot be less restrictive than the type of any of its parameters.



  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint