ControlCollection constructor

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
 
J

Juan Wajnerman

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top