【发布时间】:2014-03-15 20:28:23
【问题描述】:
我一直试图让这个 C# 程序工作,但我一直收到关于构造函数采用 1 个参数的错误。我不明白。我认为这与“Test myTest = new Test(3);”有关但我不知道如何处理它。
任何帮助或引导我朝着正确的方向前进将不胜感激。谢谢。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public class Test
{
private int tally;
public void Test(int start)
{
tally = start;
}
public void AddFive()
{
tally += 5;
}
public void Display()
{
Console.WriteLine("The tally is {0}", tally);
}
public void Main(string[] args)
{
Test myTest = new Test(3);
myTest.AddFive();
myTest.Display ();
}
}
}
【问题讨论】:
-
天哪!!!您确实遇到了 OOP 问题:P
标签: c# constructor arguments