首先大家好,这是我在这个论坛上的第一篇帖子。
我正在攻读 IT 学位的第二年完成一个项目。这是一次火的洗礼,因为它是 C# 中的 tcp/ip 实用程序,也是我第一年在 Java 基础模块中编程的唯一其他经验。
我的问题是我的部分程序使用 NetworkAdapter 类可用性属性记录 NIC 卡错误代码。我制作了一组错误代码描述,因为它们不会随代码自动返回。显然数组是基于 0 的,代码从 1 开始,我不得不将一个空值作为数组中的条目。是否有更强大的解决方案或者这是唯一的方法?我问是因为我知道数组中的空值不受欢迎。
string[] availabilityArray = new string[] {"", "Other", "Unknown", "Running or Full Power", "Warning", "In Test", "Not Applicable", "Power Off", "Off Line", "Off Duty", "Degraded", "Not Installed", "Install Error", "Power Save - Unknown" + "\n" +"The device is known to be in a power save state, but its exact status is unknown.", "Power Save - Low Power Mode" + "/n" +"The device is in a power save state, but still functioning, and may exhibit degraded performance.", "Power Save - Standby" + "/n" +"The device is not functioning, but could be brought to full power quickly.", "Power Cycle", "Power Save - Warning" + "/n" + "The device is in a warning state, though also in a power save state.",};
非常感谢
请您参考如下方法:
你的解决方案没问题。
您也可以使用 Dictionary<int, string> .
