www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons Our First C# Program Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
In this lesson we will write our first C# program. But, before doing so we need to understand some basics.

  • C# programs can be written in any text editor, but it is recommended that you use Visual Studio 2010.
  • C# program files can be saved with any extension, it is recommended that you save them with .cs extension. Visual Studio 2010 does this automatically.
  • Enough theory! now let's write our C# Hello World program:

    Program Code:
    using System;	
    // System namespace similar to a package in Java
    public class HelloWorld {
       public static void Main(){		
       // the Main function starts with capital M
       // and needs not to have the famous args []
          Console.WriteLine("Hello World!");
       }
    }
    You must be glad to see that the above code is very identical to Java and C++. The above code, when compiled and run, simply prints the words "Hello World!" to the console.

    It may be noted that just like Java and C++, C# is case sensitive. Additionally, as we have in Java, everything in C# has to be inside a class and there is no semicolon at the end of the class. However, unlike Java, name of the class and the name of the file in which it is saved needs not to match up. You are free to choose any extension for the file, but it is good to use the extension '.cs'. Like C++ and Java C# also supports single line and multi-line comments. The 'using' keyword in the first line is just a synonym of the 'import' keyword used in Java.
    Next >>> Lesson No. 5: C# Data types





    Home - Advertise - Contact - Disclaimer - About Us
    © Since 2006 pickatutorial.com -- All Rights Reserved.