我想使我定义的类的对象成为全局对象,但我收到错误。 我正在做这样的事情:
namespace HotelSystem
{
public static class GlobalVariables
{
public static login_log cashier = new login_log();
public static List<customer> customer = new List<customer>();
}
}
我得到这个错误:
Inconsistent accessibility: field type 'HotelSystem.Helpers.login_log' is less accessible than field 'HotelSystem.GlobalVariables.cashier'
Inconsistent accessibility: field type 'System.Collections.Generic.List<HotelSystem.Helpers.customer>' is less accessible than field 'HotelSystem.GlobalVariables.customer'
最佳答案
您是否尝试过错误提示?
将'public'添加到login_log类和customer类
关于c# - 如何在 C# 中创建一个全局对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22308796/