Duplicate UserControl in C # WindowsForms

0

I have a UserControl, but I need to create several of those, I tried to make an instance, but it shows me an error. Code: 'MyControl Control = new MyControl (); The error is In Both MyControl and it is as follows:

  

Error CS0246 The type or namespace name 'MyControl' could not be found (are you missing a using directive or an assembly reference?)

    
asked by Link Seb 20.05.2018 в 20:36
source

1 answer

0

Surely the namespace of the class MyControl is different from the class from which you invoke it. You must add the namespace of the class MyControl using using .

MyControl Class

namespace Proyecto.Clases
{
    public class MyControl
    {
        public MyControl() {}
    }
}

Another class

using Proyecto.Clases

namespace Proyecto
{
    public class OtraClase
    {
        public OtraClase()
        {
            MyControl mycontrol = new MyControl();
        }
    }
}
    
answered by 20.05.2018 в 20:46