5.1. Shared methods

The program given above includes four calls of methods. Two of these are calls of subroutines: these are the calls of Console.Write and Console.WriteLine. The other two calls are calls of functions: these are the calls of Console.ReadLine and Double.Parse.

Related methods can be grouped together using a class (or a structure). For example, the class Console contains methods associated with the keyboard/screen. You can deduce from the above program that it has methods called Write, WriteLine and ReadLine. And you can see that the structure Double has a method called Parse.

Another class that provides a lot of methods is a class called Math:

Double x = 2.0;
Double y = Math.Sqrt(x);

You call these methods using the notation:

In Visual Basic.NET, such methods are called shared methods: elsewhere they are called static methods or class methods. There is nothing new here: since the beginning of computing, we have had libraries of methods. So, shared methods are not exciting, and they have nothing to do with object-oriented programming.