为什么我在括号中出错? 谢谢 https://onedrive.live.com/embed?cid=B71B2418AA133D20&resid=B71B2418AA133D20%211722&authkey=AGhuiPOEiWrvNLI
class Program
{
static void Main(string[] args)
{ //ERROR!!!
public static class Calcolatrice
{
public static int Somma (int x, int y)
{
return x + y;
}
public static int Sottrazione (int x, int y)
{
return x - y;
}
}
int i = Calcolatrice.Somma(12, 3);
int j = Calcolatrice.Sottrazione(45, 34);
}
}
答案 0 :(得分:0)
您已在Main方法中定义了您的类。您需要在此之外定义您的类,可能在新文件中。
答案 1 :(得分:0)
我已经为你更正了:
internal class Program
{
private static void Main(string[] args)
{ var i = Calcolatrice.Somma(12, 3);
var j = Calcolatrice.Sottrazione(45, 34);
}
public static class Calcolatrice
{
public static int Somma(int x, int y)
{
return x + y;
}
public static int Sottrazione(int x, int y)
{
return x - y;
}
}
}