我的get
在问题中出错了,我不知道出了什么问题。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace VanDusen_PracticeObjects
{
class MathFun
{
int number1 = 4;
int number2 = 4;
int total = 0;
public MathFun()
{
}
public void MultiplyThem()
{
number1 = 2 * 2;
}
public void AddThem()
{
number2 = 2 + 2;
}
public MathFun(int innumber1, int innumber2)
{
number1 = innumber1;
number2 = innumber2;
}
public int Number1;
{
get
{
return number1;
}
set
{
number1 = value;
}
}
public int Number2;
public int Total;
}
}
答案 0 :(得分:2)
Number1
是property
并且没有分号,因此您应该在此行后删除分号:
public int Number1;
所以:
public int Number1
{
get { return number1; }
set { number1 = value; }
}