我有三个参数构造函数的恕我直言很奇怪的问题,当我尝试运行程序时,Visual Studio只显示了一个错误:“'Sort.HeapSort'不包含构造函数,它需要3个参数112 35“。C#构造函数的奇怪问题
namespace Sort
{
class HeapSort
{
private int[] A;
private int heapSize;
private int min;
private int max;
Random myRandom = new Random();
HeapSort(int size, int min1, int max1) //this is the three argument constructor.
{
heapSize = size - 1;
min = min1;
max = max1;
A = new int[size];
}
}
class Program
{
static void Main(string[] args)
{
int size = 30;
int min = 0;
int max = 100;
HeapSort myHeapSort = new HeapSort(size,min,max); //In this line is the bug
}
}
}
你有没有尝试过公开构造函数? – 2010-11-17 16:36:06
你能删除无用的线路吗?:) – ykatchou 2010-11-17 16:36:21
也许你应该用适当的访问修饰符来修饰你的类。公共,私人,保护等。 – StingyJack 2010-11-17 16:36:37