且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

泛型列表可访问性不一致

更新时间:2022-10-23 16:25:55

团队最可能内部,所以它不能在一个公共方法的签名出现在公共类。



您也可以制作团队公开或方法私人 / 内部


Here is the part of the code where I create a second form on a button click.

private List<Team> Teams = new List<Team>();
private void button2_Click(object sender, EventArgs e)
{
     Form Form2 = new Form2(Teams);
     Form2.Show();
}

Form 2:

public Form2(List<Team> teams)
{
   InitializeComponent();
}

And I'm always getting back this error:

Error 1 Inconsistent accessibility: parameter type 'System.Collections.Generic.List<Projekt.Team>' is less accessible than method 'Projekt.Form2.Form2(System.Collections.Generic.List<Projekt.Team>)'

Team is most likely internal, so it can't appear in the signature of a public method on a public class.

You can either make Team public or the method private/internal.