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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:04:27+00:00 2026-05-21T02:04:27+00:00

I have a list which is defined as List<SoftwareTitles> softwareTitlesList = new List<SoftwareTitles>(); and

  • 0

I have a list which is defined as

   List<SoftwareTitles> softwareTitlesList = new List<SoftwareTitles>();

and the SoftwareTitles is a class which is defines as follows:

public class SoftwareTitles
{
    string softwareTitle;
    string invoiceNumber;

    public SoftwareTitles(string softwareTitle, string invoiceNumber)
    {
        this.softwareTitle = softwareTitle;
        this.invoiceNumber = invoiceNumber;
    }

    string InvoiceNumber
    {           
        get
        {
            return this.invoiceNumber;
        }
    }

    string SoftwareTitle
    {
        get
        {
            return this.softwareTitle;
        }
    }
}

And now I’m adding the values from the sql server database to the list defines as follows:

 public List<SoftwareTitles> SoftwareListRetrieve()
    {
        ConnectionToSql con1 = new ConnectionToSql();
        string connectionString = con1.ConnectionStringMethod();
        SqlConnection sqlConnection = new SqlConnection(connectionString);
        SqlCommand cmd2 = new SqlCommand("SelectionOfSoftwareTitles", sqlConnection);
        cmd2.CommandType = CommandType.StoredProcedure;
        sqlConnection.Open();
        SqlDataReader dr2 = cmd2.ExecuteReader();

        if (dr2.HasRows)
        {
            while (dr2.Read())
            {
                String softwareTitle = (String)dr2[0];
                String invoiceNumber = (String)dr2[1];
                SoftwareTitles s1 = new SoftwareTitles(softwareTitle, invoiceNumber);
                softwareTitlesList.Add(s1);
            }
        }

        sqlConnection.Close();
        dr2.Close();

        return softwareTitlesList;
    }

I want to find out the software title for every occurence of invoice number by looping through List<>. And I don’t know how ? I have tried to loop through the List<> by the following code. I wanted to use something like contains i.e., softwareTitlesList[i].contains but seems like there is no such property or method

 for(int i=0; i<softwareTitlesList.Count;i++)
        {
            softwareTitlesList[i]. [BUT IT IS NOT SUGGESTING ME ANYTHING]
        }

I’m stuck with this from morning. I don’t how to solve this dilemma.

Please help me

Thanks in anticipation

  • 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-21T02:04:28+00:00Added an answer on May 21, 2026 at 2:04 am

    search for an invoice number

    string invoiceNumber = "111111111";
    

    using linq

    IList<string> titles = softwareTitlesList
        .Where(st => st.InvoiceNumber == invoiceNumber)
        .Select(st => st.SoftwareTitle);
    

    or

    IList<string> titles = softwareTitlesList
        .Where(st => st.InvoiceNumber.Contains(invoiceNumber))
        .Select(st => st.SoftwareTitle);
    

    w/o using linq, it’s still pretty basic

    IList<string> titles = new List<string>();
    foreach(var softwareTitle in softwareTitlesList)
    {
        if (softwareTitle.InvoiceNumber.Contains(invoiceNumber))
            titles.Add(softwareTitle.SoftwareTitle);
    }
    

    you could also rewrite your class like this:

    public class SoftwareTitles
    {
        public SoftwareTitles(string softwareTitle, string invoiceNumber)
        {
            SoftwareTitle = softwareTitle;
            InvoiceNumber = invoiceNumber;
        }
    
        public string InvoiceNumber { get; private set; }
    
        public string SoftwareTitle { get; private set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Software titles class which is defined as follows: public class SoftwareTitles
I have a listView which defined like this in xml: <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=match_parent
I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have a List View in which I have defined a custom cell as
I have a list which I call #gallery in which I've defined a couple
I have a class which has the following constructor public DelayCompositeDesigner(DelayComposite CompositeObject) { InitializeComponent();
I have got four routes defined like this: //Project list with page number routes.MapRoute(
I am having a dictionary which was defined as follows Dictionary<int, List<int>> dict1 =
I have generic list which must be a preserved order so I can retrieve
I have a list which I have obtained from a python script. the content

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.