Labels

Programming with C# - Lesson 01

What is .Net Framework ? 

The .NET Framework is a revolutionary platform that helps you to write the following types of Applications.
  • Windows Applications
  • Web Applications
  • Web Services

 What is C# - Programming Structure
  • Name Space Declaration
  • A Class
  • Class Methods
  • A Main Method
  • Statements & Expressions
  • Comments





Sample Code in C#


01. using Systems;

02. namespace HelloWorldApplication {
03.   class HelloWorld {
04.      static void Main (string[] args) {
05.         /* My first program in C# */
06.         Console.WriteLine("Hellow World");
07.         Console.ReadKey()
       }
   }
}
Lets go through with the above code ...


  01. The first line of the program using System, The using keyword is used to include the System namespace in the program. A program generally has multiple using statements.

02. The next line has a namespace declaration. A namespace is a collection of classes. The Hello World Application contain the class HelloWorld.

03. The next line has a Class declaration. The Class HelloWorld contains the data and method definition that your program uses. Classes generally would contain more that one method. Methods define the behavior of the class. However the HelloWorld Class has only one method Main.

04. The next line defines the Main method which is the entry point for all C# Programs. The main method states what the class will do when executed.

05.  The main method specifies its behavior with the statement Console.WriteLine("Hello World");

06. The next line /* ... */ will be ignored by the compiler and it has been put to add additional comments in the program.

07.  WriteLine is a method of the Console class defined in the System namespace. This statement causes the message "Hello, World!" to be displayed on the Screen.

08.  The last line Console.ReadKey(); is for the VS.NET users. This makes the program wait for a key press and it prevents the screen from running and closing quickly when the program is launched from VisualStudio.Net

Next Time we will see how to write above code using Visual Studio 2013 ...
 

No comments: