. Operator (C# Reference)
Visual Studio 2008
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:
For example, consider the following class:
The variable s has two members, a and b; to access them, use the dot operator:
The dot is also used to form qualified names, which are names that specify the namespace or interface, for example, to which they belong.
The using directive makes some name qualification optional:
But when an identifier is ambiguous, it must be qualified:
namespace Example2 { class Console { public static void WriteLine(string s){} } } namespace Example1 { using System; using Example2; class C { void M() { // Console.WriteLine("hello"); // Compiler error. Ambiguous reference. System.Console.WriteLine("hello"); //OK Example2.Console.WriteLine("hello"); //OK } } }
For more information, see the following sections in the C# Language Specification:
-
7.5.4 member access