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 6641115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:46:21+00:00 2026-05-25T23:46:21+00:00

At the top of my code (before constructor) I write: String[] CAN = null;

  • 0

At the top of my code (before constructor) I write:
String[] CAN = null;

This string array is updated in another function.

Later in my code I have this foreach loop:

foreach (String str in CAN)
{
    if(str.Contains("18FA07FE"))
        cmdResult = true;
    else
        cmdResult = false;
}

I have tried to debug, and at the line of the foreach statement I can see that the CAN string array has successfully been updated, and now contains 1211 elements.

So I don’t really know why it’s giving me this exception.

  • 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-25T23:46:22+00:00Added an answer on May 25, 2026 at 11:46 pm

    If the problem is only related to the code you’ve shown, and the code you’ve described, and it’s true that the array has elements, then the only possible explanation is that one of the elements in CAN is a null element, and thus it isn’t the foreach itself that throws the exception, but this line:

    if (str.Contains(...))
        ^^^
         |
         +-- null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I have code that is working (posted after this) but before I expand
I have code in the top layer of my .Net web application that I'd
Anyone have code to set margins(top,left,right,bottom) using excel interop and vb.net. I think it
I have the following code in the top frame of a two frame page:
All my controller has this code on the top of class. public class TestController
This is my code [...] final String[] top_spinner_items = new String[35]; for (int i
I have a php-file which includes another html-file: <? virtual(../top.html);?> The problem is that
I have a popup window code that I have used before in login forms.
Can somebody help me? The following code works, but unfortunately a function call to
this is probably going over the top, but I was after a function that

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.