Your first C# Program Tutorial

Description

Let's start by compiling and running the simplest possible C# program.

Source Code

Type the following into a text editor, and save it as First.cs.


using System; /*from w w  w. ja  v a2s. co m*/
           
public class MyFirstClass 
{ 
   static void Main() 
   { 
      Console.WriteLine("Hello from java2s.com."); 
      Console.ReadLine(); 
      return; 
   } 
}  

Compiling and running

You can compile this program by simply running the C# command - line compiler ( csc.exe ) against the source file, like this:

csc First.cs

Compiling the code produces an executable file named First.exe.


csc First.cs  /*from   w w  w.j  a  va  2  s  . c  o  m*/
Microsoft (R) Visual C# 2010 Compiler version 4.0.20506.1  
Copyright (C) Microsoft Corporation. All rights reserved. 
                         
First.exe  
Hello from java2s.com.    




















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception