0

我正在尝试创建用于存储信息的类实例列表,但出现此错误:

Error 1 Inconsistent accessibility: property type 'System.Collections.Generic.List<POS_System.ReportReciepts>' is less accessible than property 'POS_System.Reports24Hours.recieptlist'

任何线索为什么?我试过弄清楚,但我不知道这是怎么回事。这是我抛出错误的代码和我的课程。谢谢!

public partial class Reports24Hours : Form
{
    string category = "";
    public int WhichReciept = 0;
    public static List<ReportReciepts> recieptlist { get; set; } //Error here
    ...
}

.

class ReportReciepts
{
    public string[] Quantity { get; set; }
    public string[] ItemName { get; set; }
    public string[] Price { get; set; }
}
4

2 回答 2

1

您的 ReportReceipts 需要公开。本质上,您正在制作一个公开的项目列表,但项目的类型是私有的,所以没有人可以看到它。这应该有效:

public partial class Reports24Hours : Form
{
    string category = "";
    public int WhichReciept = 0;
    public static List<ReportReciepts> recieptlist { get; set; } //Error here
    ...
}



public class ReportReciepts
{
    public string[] Quantity { get; set; }
    public string[] ItemName { get; set; }
    public string[] Price { get; set; }
}
于 2013-11-14T19:01:10.803 回答
0

你需要制作ReportReciepts public. 类的默认访问修饰符是internal,但您试图从属性返回 a Listof 。通过公共属性公开的任何类型本身必须是公共的。ReportRecieptspublic

于 2013-11-14T19:00:49.757 回答