Creating a Simple Hello World Application

A simple hello world application written in C# follows:

namespace HelloWorld
{
    using System;
    public class Hello
    {
        public Hello()
        {
            // Constructor logic goes here
        }
        public static int Main(string[] args)
        {
      Console.WriteLine("Hello: ");
         if (args.Length==0)
        Console.WriteLine("who ever you are!");
      else
         for (int i=0;i<args.Length;i++)
        Console.Write(" {0} ", args[i]);
           return 0;
        }
    }
}

Let's examine the code a little deeper. First, notice that the code is enclosed within a namespace called HelloWorld

namespace HelloWorld
{
//...
}

The class name is Hello, therefore, the full name of the class that I have declared here is called HelloWorld.Hello, that is, the name is [NamespaceName].[ClassName].

Note

The fact ...

Get .NET and COM Interoperability Handbook, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.