2013年8月5日 星期一

c # Hello World

install-c# install-c-sharp
http://cscsharp.cs.uvic.ca/installCSharp.shtml

http://msdn.microsoft.com/en-us/library/vstudio/a72418yk.aspx

ProgramName.cs

// A Hello World! program in C#.   <= remark

/* A "Hello World!" program in C#.
This program displays the string "Hello World!" on the screen. */ <= remark

using System;  // java import
namespace HelloWorld // java package
{
    class Hello
    {
        static void Main() // must contain a Main method
        {
            Console.WriteLine("Hello World!");
            // Keep the console window open in debug mode.
            Console.WriteLine("Press any key to exit.");  // System.out.print()
            Console.ReadKey();
        }
    }
}


Compile

csc ProgramName.cs  // javac
Result : ProgramName.exe // javaFileName.class


More about : Main

static void Main() {}
static int Main(){ return 0;}
static void Main(string[] args){}
static int Main(string[] args){return 0;}

沒有留言:

張貼留言