我很慚愧,這是在C#中完成的最基本的任務,我似乎無法弄清楚。是的,我可以編譯它並使其運行,但是我想對它進行剖析並逐字理解它。C#基礎理解問題
using System; *//"include standard System classes"*
namespace DataTypeApplication *//"Create new classes within DataTypeApp..."*
{
class Program *//"Name this class "Program""*
{
static void Main(string[] args) *//Declares the main function of this class?*
{
Console.WriteLine("Size of int: {0}", sizeof(int)); *//Print string using sizeof(int)*
Console.ReadLine(); *//Irrelevant*
}
}
}
我很困惑,爲什麼會這樣運行。程序已創建但未被調用。而且,這會爲int輸出4,但是這4個來自哪裏呢?
我很感謝任何幫助理解這一點,但也許C#只是不適合我。 -_-
「int」是「In32」,意思是32位是4字節。 –
'sizeof(int)'返回4個字節的int類型的大小。這是爲字符串中的「{0}」佔位符插入的。 「ReadLine」要求用戶輸入,並且是一種讓程序保持活動狀態直到讀取完整輸出的方式。其餘是正確的。 – poke
查看項目屬性,你會看到「Program.Main」是「入口點」的位置 – DaveShaw