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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:45:31+00:00 2026-05-17T15:45:31+00:00

I am using the following code in C#. I am adding the values into

  • 0

I am using the following code in C#. I am adding the values into the arraylist by using index. Now I want to read the values from the arraylist by using the index only. In the following example I am simply reading all the values from the arrylist but I want to read the values from the arrylist based on index( for e.g Customer_Details[i]) for each element at index i.

 public struct Cust_Info
        {
            public String Client_Key;
            public String Registration_Key;
            public int Standard;

            public Cust_Info(String C_Key, String Reg_Key, int Std)
            {
                Client_Key = C_Key;
                Registration_Key = Reg_Key;
                Standard = Std;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ArrayList Customer_Details = new ArrayList();
            for (int i = 0; i < 1; i++)
            {
                Customer_Details.Insert(i, new Cust_Info("A", "B", 1));
            }

            //for (int i = 0; i < 1; i++)
            //{
                Customer_Details.Insert(1, new Cust_Info("C", "D", 2));
                for (int i = 0; i < 1; i++)
                {
                    ArrayList obj=new ArrayList();
                    //((ArrayListOFStructures.Form1.Cust_Info)((new System.Collections.ArrayList.ArrayListDebugView(Customer_Details)).Items[0])).Client_Key
                    //obj = (ArrayList)Customer_Details[i];
                    foreach (Cust_Info temp in Customer_Details)
                    {
                        //comboBox1.Items.Add(Customer_Details[0].ToString());
                        comboBox1.Items.Add(temp.Client_Key);
                        comboBox1.Items.Add(temp.Registration_Key);
                        comboBox1.Items.Add(temp.Standard);
                    }
                }
        }

In the above code i want to make the use the structure only. How can I read the values from the arrylist based on index. Can you please provide me any code or link through which I can resolve the above issue ?

  • 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-17T15:45:32+00:00Added an answer on May 17, 2026 at 3:45 pm

    I’m confused; you can get an item out of an ArrayList by index simply by:

    Cust_Info cust = (CustInfo)theList[index];
    

    However, ArrayList is pretty rare in anything >= .NET 2.0, a List<Cust_Info> would make this much easier. Also, Cust_Info looks to me very much like it should be a class (it is very rare to write a struct in .NET, and usually to denote “values” – a customer isn’t a “value”). And public fields are also very much discouraged.

    Note that currently you are (because it is a struct) actually copying the Cust_Info whenever you fetch it from (or place it in) the list; that isn’t necessarily what you intend…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code --- EDIT @annakata : Adding the complete code
I'm using the following code to query a database from my jsp, but I'd
I'm using the following code within the JCProperty class to retrieve data from a
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
I've been using the following code to open Office Documents, PDF, etc. on my
I am using following PHP code to connect to MS Access database: $odb_conn =
I am currently using the following code to create a web request: Dim myRequest
I'm using the following code, using the SharpZipLib library, to add files to a
I'm using the following code to loop through a directory to print out the
I am using the following code: <?php $stock = $_GET[s]; //returns stock ticker symbol

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.