我不太理解以下简单代码的问题。它只是接收一个列表并在datagridview中显示。这是我得到的错误信息:
Error 1 Inconsistent accessibility: return type 'System.Collections.Generic.List' is less accessible than method 'WindowsFormsApplication10.Form1.FillGridView()'
此外,有没有一种方法将您的列表、arraylist等转换为数据集类型?
public partial class Form1 : Form
{
public Form1 ()
{
InitializeComponent ();
}
public List<Student> FillGridView ()
{
List<Student> l = new List<Student> ();
l.Add (new Student { Fname="bloke", Lname="lll", Contact=293489485});
l.Add (new Student { Fname = "dog", Lname = "assdf", Contact = 35345 });
l.Add (new Student { Fname = "mary", Lname = "sdff", Contact = 6456 });
l.Add (new Student { Fname = "john", Lname = "sdfsdf", Contact = 45656 });
return l;
}
private void Form1_Load ( object sender, EventArgs e )
{
dataGridView1.DataSource = this.FillGridView ();
}
private void button1_Click ( object sender, EventArgs e )
{
}
}
Student
类吗? - Arshad