gpt4 book ai didi

c# - 如何在 C# 中创建一个全局对象?

转载 作者:太空宇宙 更新时间:2023-11-03 17:52:05 25 4
gpt4 key购买 nike

我想使我定义的类的对象成为全局对象,但我收到错误。我正在做这样的事情:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com