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

  • SEARCH
  • Home
  • 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 8236679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:12:45+00:00 2026-06-07T19:12:45+00:00

I am struggling to find a solution to this problem. I see lots of

  • 0

I am struggling to find a solution to this problem. I see lots of simlilar entries on this site that touch upon this subject, but I can’t seem to arrive at a solution. I am trying to check a table in cache to see if it already exists and if not, populate it. Below is my code for that check and it errors on the ‘if’ statement telling me ‘System.NullReferenceException: Object reference not set to an instance of an object’. This is puzzling because shouldn’t the ‘.IsNullOrEmpty’ catch this? I figure if the 1st element in the array is null or empty then it hasn’t been cached yet and therefore take action.

            string[] saveCatList = Cache["Categories" + Session["sessopnID"]] as string[];
            if (string.IsNullOrEmpty(saveCatList[0]))
            {
                WBDEMOReference.getcatlist_itemcategories[] categories;
                strResult = callWebServ.getcatlist(Session["sessionID"].ToString(),
                            out strResultText, out dNumOfCat, out categories);

                for (int i = 0; i < categories.Length; i++)
                {
                    //ddCat is the ID number of the category drop down list
                    ddCat.Items.Add(new ListItem(categories[i].categorydesc.ToString(),
                                                 categories[i].categorynumber.ToString()));
                }
            }
  • 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-06-07T19:12:47+00:00Added an answer on June 7, 2026 at 7:12 pm

    With string.IsNullOrEmpty(saveCatList[0]) you check if first element of array is empty or null. It seems that your array is null, so you should firstly check your array:

    if(saveCatList == null || string.IsNullOrEmpty(saveCatList[0]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a common problem but I'm struggling to find a solution that
I have been struggling to find a solution to this problem. In my code,
This is a basic question but I am struggling to find a decent solution.
I'm struggling to find a good solution to this problem. In a view controller's
I been struggling and looking everywhere but can not find solution to this. I
I'm struggling to find a decent walkthrough for this issue, and was hoping that
I've been struggling through SO and the Mule forums but can't find a solution
I m struggling with this issue for so long but not able to find
I'm struggling to find a solution for this anywhere on Google, maybe i'm searching
While I'm still struggling to find a solution for this question, i have another

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.