C#: The dot operator

This entry is part 13 of 71 in the series C#

The dot operator (.) is used for member access. The dot operator specifies a member of a type or namespace.

For example, the dot operator is used to access specific methods within the .NET Framework class libraries as in line 11 and 12 below.

using System;

namespace Hello
    class Program
        static void Main()
            string name;

            Console.WriteLine("Hello, what is your name?");
            name = Console.ReadLine();
            Console.WriteLine("Your name is " + name);

In our example above, Console is a class under System namespace. We are using 2 member functions or methods namely, WriteLine() and ReadLine().

The member functions or methods of a class are accessed by the dot operator.


Series Navigation<< C#: The Main function
C#: Accessing methods using dot >>
Posted in