类型或命名空间名称' get'无法找到

时间:2015-10-14 14:18:22

标签: c# get namespaces

我的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;
   }
}    

1 个答案:

答案 0 :(得分:2)

Number1property并且没有分号,因此您应该在此行后删除分号:

public int Number1;

所以:

public int Number1
{
    get { return number1; }
    set { number1 = value; }
}