How to declare a constructor?

后端 未结 3 739
逝去的感伤
逝去的感伤 2021-01-28 07:42

I get the following error when I compile the program

\"Microsoft.Samples.Kinect.ControlsBasics.SelectionDisplay\' does not contain a constructor that ta

3条回答
  •  耶瑟儿~
    2021-01-28 08:36

    Well, you've already created a constructor that takes one argument:

    public SelectionDisplay(string itemId)
    {
        //...
    }
    

    But you're passing it two arguments:

    new SelectionDisplay(button.Label as string, button.Tag as string);
    

    You can add an argument to the constructor you have, or create a new one:

    public SelectionDisplay(string itemId, string someOtherValue)
    {
        //...
    }
    

提交回复
热议问题