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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:53:42+00:00 2026-05-20T19:53:42+00:00

Below is a snippet of code i am trying to use to search an

  • 0

Below is a snippet of code i am trying to use to search an arraylist for. I have used code very similar to this in a different form and it has worked. However here it has not. It is meant to search for the Customer Number within the Arraylist on frmMain, it then searches for that customers Account Number typed in by the user. But for some reason it is almost as if it skips the second if statement and go to the error message at the bottom.

The Arraylist is on the frmMain, then there are classes for Customer Account and Transaction. In Customer there is another ArrayList storing the Accounts, then in the Account Class there is an ArrayList storing the transactions of the customer account.

        foreach (Customer a in frmMain.bankDetails)
        {
            if (a.getCustomerNumber().ToUpper().Equals(custSearch))
            {
                foreach (Account b in a.Accounts)
                {
                    if (b.getAccNumber().Equals(searchString))
                    {
                        txtSearch.BackColor = Color.PaleGreen;
                        txtAccSortCode.Text = b.getAccSort();
                        txtAccNumber.Text = Convert.ToString(b.getAccNumber());
                        txtAccNickName.Text = b.getAccNick();
                        txtAccDate.Text = b.getAccDate();
                        txtAccCurBal.Text = Convert.ToString(b.getAccCurBal());
                        txtAccOverDraft.Text = Convert.ToString(b.getAccOverDraft());
                        txtNumTrans.Text = Convert.ToString(b.getAccNumTrans());
                        found = true;
                        break;
                    }
                }
            }
        }

Any help appreciated!

  • 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-20T19:53:43+00:00Added an answer on May 20, 2026 at 7:53 pm

    If b.getAccNumber() is returning an int and searchString is a string, then it will always return false. For example:

    int int_four = 4;
    string string_four = "4";
    bool eq1 = int_four.Equals(string_four); // false
    bool eq2 = int_four.ToString().Equals(string_four); // true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is a snippet of code that is trying to post to a PHP
In the code snippet below, I am trying to persist two entities - Account
I have below snippet of code in which TestClass is extending jPanel which is
I have below code snippet SimpleDateFormat dateFormat = new SimpleDateFormat( yyyy-MM-dd hh:mm:ss.SSS); String processedContentDate=2012-04-10
I'm trying to understand 2 different lines of code below. My javascript is weak,
Below is a code snippet of some frames I am trying to traverse using
Below is my code and I have been trying to color the cells but
The below code snippet leaks when i am trying the build and analyse thing.
The below code snippet best explains what I am trying to achieve: [Test] public
i am trying to implement curl effect by using below code snippet curl down

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.