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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:47:52+00:00 2026-06-07T22:47:52+00:00

i have a user defined list public class Level2 { public double price {

  • 0

i have a user defined list

public class Level2
{
    public double price { get; set; }
    public int size { get; set; }

    public Level2(double price, int size)
    {
        this.price = price;
        this.size = size;
    }
}

in my program i have this snippet which i loop through the first 10 elements

List<Level2> bid = new List<Level2>();

        for (int i = 0; i < 10; i++)
        {
            if (i < bid.Count && bid[i].price > bid[0].price - (20 * process.tickSize))
            {
                bidString = bidString + "," + bid[i].price.ToString() + "," + bid[i].size.ToString();
            }                
        }

and it compile and runs fine.
Now i need to expand my program and want to change my variable to an array type, like this:

 List<Level2>[] bid = new List<Level2>[5];

how can i change my loop, so i can loop through the first array, ie bid[0] ?

please provide some working snippet, thank you very much

  • 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-07T22:47:54+00:00Added an answer on June 7, 2026 at 10:47 pm

    Replace all bid with bid[0]

    List<Level2>[] bid = new List<Level2>[5]; 
    
        for (int i = 0; i < 10; i++) 
        { 
            if (i < bid[0].Count && bid[0][i].price > bid[0][0].price - (20 * process.tickSize)) 
            { 
                bidString = bidString + "," + bid[0][i].price.ToString() + "," + bid[0][i].size.ToString(); 
            }                 
        } 
    

    Alternatively use a different variable for the bid array

    List<Level2>[] bidArray = new List<Level2>[5];
    

    then assign bid to be the first element

    List<Level2> bid = bidArray[0];
    

    and then continue with your existing code.

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

Sidebar

Related Questions

I have this user defined function. public partial class UserDefinedFunctions { static int i;
I have a user defined class that I want to create a public List
I have a class Bar that has a user-defined list of config keys and
I have a model like this defined... public class Product{ private long timestamp; //
Assume I have a user defined Java class called Foo such as: public class
I have a table a with a list of id's, and a user-defined function
I have a class that defined a user defined operator for a TCHAR*, like
in my Silverlight 4 Application, I have an observable list of a user defined
I have a little engine (defined as public class ScreenManager : DrawableGameComponent ) to
Background: I have a List<T> in my ViewModel defined as... private List<FooBar> _fooBars; public

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.