HelloWorld

HelloWorld 예제

// Hello1.cs
public class Hello1
{
   public static void Main()
   {
      System.Console.WriteLine(“Hello, World!”);
   }
}

// Hello2.cs – using System을 사용
using System;


public class Hello2
{
   public static void Main()
   {
      Console.WriteLine(“Hello, World!”);
   }
}

// Hello3.cs – program argument 를 처리
// arguments: A B C D
using System;


public class Hello3
{
   public static void Main(string[] args)
   {
      Console.WriteLine(“Hello, World!”);
      Console.WriteLine(“You entered the following {0} command line arguments:”,
         args.Length );
      for (int i=0; i < args.Length; i++)
      {
         Console.WriteLine(“{0}”, args[i]);
      }

   }
}

// Hello4.cs – Main 메소드에 반환인자를 넣을 경우
using System;


public class Hello4
{
   public static int Main(string[] args)
   {
      Console.WriteLine(“Hello, World!”);
      return 0;
   }
}

Leave a Reply

Your email address will not be published. Required fields are marked *