Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3997526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:24:46+00:00 2026-05-20T07:24:46+00:00

Firstly Hello, This is my first post on this forum. I am completing a

  • 0

Firstly Hello, This is my first post on this forum.

I am completing a project in my second year of an IT degree. It’s a baptism of fire as it’s a tcp/ip utility in C# and my only other experience of programming in a foundation module in Java in the first year.

My problem is that part of my programm logs NIC card error codes using NetworkAdapter class Availability property. I have made an array of the error code descriptions as they are not automatically returned with the code. Obviously arrays being 0 based and the codes start at 1 I have had to put a null value as the entry in the array. Is there a more robust solution or is that the only way? I ask because i understand that null values in arrays are frowned upon.

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.",};

Many Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:24:47+00:00Added an answer on May 20, 2026 at 7:24 am

    There are multiple ways to handle this:

    1. Keep your first element
    2. Subtract 1 from each error code before looking it up:

      string text = availabilityArray[errorCode - 1];
      
    3. Use a dictionary:

      Dictionary<int, string> availability = new Dictionary<int, string>
      {
          { 1, "Other" },
          { 2, "Unknown" },
      };
      

      This would also handle gaps, you could easily skip to code 10 in the above list and continue, but you would need explicit code to detect whether an error code is present in the dictionary:

      string text;
      if (availability.TryGetValue(errorCode, out text))
          // is there
      else
          // is not
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly: apologies if this is a duplicate post. Things got a bit confusing as
Firstly, this is not a question about repository synchronisation for which there are numerous
Firstly, is it possible? Been struggling with this one for hours; I think the
Firstly, I want to restrict this question to web development only. So this is
Firstly, this seems like (from ContourPlot) a fairly straightforward maximization problem, why is FindMaximum
Firstly, let me set out what I'd like to do. Assume I have three
Firstly, I'm a newbie to C# and SharePoint, (less than a month's experience) so
Firstly, Real World Haskell , which I am reading, says to never use foldl
So firstly here's my query: ( NOTE:I know SELECT * is bad practice I
I wish to order a table: Firstly by Field1=3 Then by Field2 DESC I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.