首先你好,這是我在這個論壇上的第一篇文章。數組問題 - 關於索引。 c#
我正在完成一個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.",};
非常感謝
是連續值無覆蓋差距?即。你有錯誤代碼1-N而不是1-4,10-18,100-199等。 – 2011-02-24 12:51:14
順便說一句,這不是一個空引用;它是一個空字符串。 – Ani 2011-02-24 12:53:01
^^^感謝指出:) – 2011-02-24 13:27:36