ControlCollection constructor

  • Thread starter Thread starter K
  • Start date Start date
K

K

Can anyone tell me why VB can successfully inherit from the
ControlCollection class but C# can't?

When compiling the following 2 classes, the C# version gets a compile error
of:

"No overload for method 'ControlCollection' takes '0' arguments"


// C#

public class Class1 : System.Windows.Forms.Form.ControlCollection

{

public Class1(System.Windows.Forms.Control owner)

{

}

}

' Visual Basic

Public Class Class11

Inherits System.Windows.Forms.Form.ControlCollection

Public Sub New(ByVal owner As System.Windows.Forms.Control)

End Sub

End Class
 
Try this:

public class Class1 : System.Windows.Forms.Form.ControlCollection
{
public Class1(System.Windows.Forms.Form owner) : base(owner)
{
}
}

In your code, you are specifying Control parameter in constructor.
That is for Control.ControlCollection.
 
Back
Top