使用列表不一致的可访问性 [英] Inconsistent Accessibility using lists
本文介绍了使用列表不一致的可访问性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建用于存储信息的类实例列表,但出现此错误:
I'm trying to create a list of class instances for storing information, but I'm getting this error:
错误 1 不一致的可访问性:属性类型System.Collections.Generic.List
知道为什么吗?我试图弄清楚,但我不知道这是什么.这是我抛出错误的代码和我的课程.谢谢!
Any clue why? I've tried figuring out but I have no idea whats throwing this. Heres my code where the error is being thrown and my class. Thanks!
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; }
}
推荐答案
您的 ReportReceipts 需要公开.本质上,您正在制作一个公开的项目列表,但项目的类型是私有的,因此没有人可以看到它.这应该有效:
Your ReportReceipts needs to be Public. Essentially you're making a public list of items, but the type of item is private, so no one can see it. This should work:
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; }
}
这篇关于使用列表不一致的可访问性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文