C#入門編-1:HelloWorldのクラス
5843 ワード
using System;
//001: HelloWorld
namespace C001
{
class HelloWorld
{
#region 01 Hello,World
// Main
public static void Main(string[] args)
{
// Hello, World! ctrl+F5, cmd “Hello, World!”
//
Console.WriteLine("Hello, World!");
}
#endregion
#region 02 , ?
public static void Main(string[] args)
{
string strName; // string
Console.Write("please input your name:"); // ,
strName = Console.ReadLine(); // ,
Console.WriteLine("hello, {0}!", strName); // hello
}
#endregion
#region 03 main ?
public static void Main(string[] args)
{
//Main string[] ,
// string
string strName;
try
{
// strName
strName = args[0];
// , , try···cache
//
Console.WriteLine("This is the first argument: {0}!", strName);//"{0}"
// : ?
// ,
}
catch (System.IndexOutOfRangeException e)
{
Console.WriteLine(e.Message);
}
}
#endregion
/* ?
cmd “cd” C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
:csc hello.cs, EXE , cmd
?
win7 -- -- -- --path 【 ";" 】
?
csc /target:library a.cs a.dll
exe ?
EXE " .exe"
?
*/
}
}
! ,