O'Reilly logo

.NET Programming: A Practical Guide Using C# by Pradeep Tapadiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Simple “Hello User” Program

Let's get right down to business. The following program displays a greeting to the console:

// Project HelloUser

class MyApp
{
     public static void Main() {
       System.String userName = "Jay";
       System.Console.WriteLine("Hello " + userName);
     }
}

This simple application defines a class called MyApp that has a single static public method called Main. Under .NET, methods must generally be members of a class or a struct. A class or a struct form the basic unit of organization under .NET and are generally referred to as types. We explore the differences between a class and a struct in detail in Chapter 4.

Static method Main is considered the entry point for the program. When the program is run, the .NET runtime starts executing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required