I've an object called "Catalogo" that's an array of other objects, i use it in Form1 and i wanna use the same instance in Form 2, but I can't pass it as a parameter, the compiler gives me the error CS0051, but I'm not able to find where I wrong. Can someone help me? That's my code:
Form1:
public partial class Form1 : KryptonForm
{
Catalogo main = new Catalogo();
public Form1()
{
InitializeComponent();
}
//when I click the button, create and open a new form2, passing main as a parameter
private void KryptonButton1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2(main);
form2.Show()
}
}
Form 2:
public partial class Form2 : KryptonForm
{
public Form2(Catalogo test)
{
InitializeComponent();
}
}
Catalogo class:
class Catalogo
{
public Catalogo()
{
//constructing method
}
}
Thanks to anyone who will help me!
CodePudding user response:
Make Catalogo
accessible (i.e. public)
public class Catalogo
{
public Catalogo()
{
//constructing method
}
}