【问题标题】:Passing an Object between Forms in C#在 C# 中的窗体之间传递对象
【发布时间】:2013-08-25 11:10:10
【问题描述】:

我创建了一个学生对象数组,我想从一种形式传递到另一种形式。当我尝试这样做时,我得到“

Inconsistent accessibility: parameter type 'College_Life.Student[]' is less accessible than method 'College_Life.frmStudentOutput.frmStudentOutput(College_Life.Student[])

第一个表格如下所示:

namespace College_Life
{
    public partial class frmInput : Form
    {
        private int intCount;
        private Student[] ALevel = new Student[1];
.
.
.
        private void cmdSort_Click(object sender, EventArgs e)
        {
            //
            frmStudentOutput OutputForm = new frmStudentOutput(ALevel);
            OutputForm.Show();
        }

。 . . 第二种形式看起来像

    private Student[] ALStudent;

    public frmStudentOutput(Student[] ALStudent)
    {
        InitializeComponent();

希望你能帮忙 谢谢

【问题讨论】:

    标签: c# object parameter-passing


    【解决方案1】:

    打开 Student 类并检查它是否是公开的。

    应该是这样的:

    public class Student
    {
        public Student()
        {
             //...
        }
        //...
    }
    

    【讨论】:

      猜你喜欢
      • 2015-03-19
      • 1970-01-01
      • 2011-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多