程式進入點:Main
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
//這裡是你要寫程式碼的地方
}
}
}
顯示文字:Console.Write("文字內容");
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.Write("Hello World!");
Console.Write("Hello C#!");
}
}
}
顯示文字後換行:Console.WriteLine("文字內容");
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine("Hello C#!");
}
}
}
接收一行輸入:Console.ReadLine();
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine("Hello C#!");
Console.ReadLine();
}
}
}
清空輸出:Console.Clear();
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.ReadLine();
Console.Clear();
Console.WriteLine("Hello C#!");
Console.ReadLine();
}
}
}
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!\nHello C#!");
Console.ReadLine();
Console.Clear();
Console.WriteLine("Hello World!\tHello C#!");
Console.ReadLine();
Console.Clear();
Console.WriteLine("\\Hello World/\\Hello C#/");
Console.ReadLine();
Console.Clear();
Console.WriteLine("\"Hello World! Hello C#!\"");
Console.ReadLine();
Console.Clear();
}
}
}