我是C#的新手,在我的教科書中,它要求我向Program.cs類的主要方法中添加一些代碼,但沒有告訴我如何。我是一名初學者,所以我只是在尋找基礎知識,而當我出發時,我會拿起更先進的課程,所以請讓你的解釋徹底,但下降到第1級。以下是我提供的代碼。它不斷地爲我提供了錯誤的<瞭解C#代碼機制
這裏是下面的代碼:我應該向公衆靜態聲音TestIfElse方法添加到Program.cs文件類:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ifelse_Statement
{
class Program
{
static void Main(string[] args)
{
TestIfElse(10);
public static void TestIfElse(int n)
{
if (n < 10)
{
Console.WriteLine(「n is less than 10」);
}
else if (n < 20)
{
Console.WriteLine(「n is less than 20」);
}
else if (n < 30)
{
Console.WriteLine(「n is less than 30」);
}
else
{
Console.WriteLine(「n is greater than or equal to 30」);
}
}
}
}
}