ここにあります:
2 つのフォームと 1 つのクラスがあります。このクラスのインスタンスを Form1 から Form2 にパラメーター (2 番目のフォームのコンストラクターに属する) を介して渡したいと考えています。
public partial class Form1 : Form
{
Class1 cl = new Class1();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm_2 = new Form2(cl);
}
}
したがって、次のエラーが表示されます。
一貫性のないアクセシビリティ: パラメータ タイプ 'WindowsFormsApplication1.Class1' は、メソッド 'WindowsFormsApplication1.Form2.Form2(WindowsFormsApplication1.Class1)' よりもアクセスしにくい
public partial class Form2 : Form
{
public Form2(Class1 c)
{
InitializeComponent();
Class1 c_1 = new Class1();
c_1 = c;
}
}
ありがとう。