C#: namespace and class

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

Using the earlier simple program, we go through the components of a C# program.

using System;

namespace ConsoleHelloApplication
    class Program
        static void Main(string[] args)
            Console.WriteLine("Hello, World");

A namespace is a collection of classes.

Here in our simple program, there are actually 2 namespaces namely, System and ConsoleHelloApplication.

For the namespace ConsoleHelloApplication, we have only one class known as Program.

For the namespace System, we have used Console class to print out a line.

In an object-oriented program, we commonly say that Program class is a member of namespace ConsoleHelloApplication.

We can also say that the Main function is a member of Program class.

There is one more class here with 2 member functions.  Are you able to name the 2 member functions?

Well, the class is Console and the 2 member functions are WriteLine() and ReadLine().  The 2 member functions are also called the methods of Console class.

Series Navigation<< C#: Learning An Object-Oriented Programming Language
C#: Reading input using Readline() >>

Leave a comment

Leave a Reply