C#与构造函数的奇怪问题

Kon*_*rad 1 c# constructor

我有三个参数构造函数的恕我直言非常奇怪的问题,当我尝试运行程序时,visual studio只显示一个错误:"'Sort.HeapSort'不包含一个带有3个参数的构造函数112 35".

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
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

cdh*_*wie 9

您的构造函数被声明为private,因为您省略了访问说明符.public在构造函数定义之前添加关键字.