Defining Methods
A method can be defined as either a static or an instance member, which influences what state is available to it. You’ve seen the use of a special static method plenty of times, namely an application’s entry point Main method:
class Program{ static void Main(string[] args) { ... }}
Of the modifiers available on a method declaration, we’ve only used the static one. Many other modifiers exist to specify things such as visibility (public, private, internal, and the object-oriented [OO]-related protected and protected internal access modifiers). You’ll see more of those modifiers in Chapter 14, “Object-Oriented Programming,” including abstract, virtual, override, sealed, and new.
The declaration of a method consists ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access