I am trying to declare dimensions like this but this example does not compile.
I think the declarations might be something wrong with but cant figure it out what it can be:

class Dime1 : List<String> { };
class Dime2 : List<Dime1> { };
Dime2 Dim3 = new Dime2();

      for( int j = 0; j < 1000; j++ ) 
      {
            Dim3.Add(new Dime1()); 
         
            for( int i = 0; i < 1000; i++ ) 
            { 
               Dim3[j].Add("0");
            }
      }

Recommended Answers

All 4 Replies

Never did this but you could declare a List of List :
List<List<string>> dim2 = new List<List<string>>();

Hello, Darth Vader.

Just to make sure - is your code is a holistic part of code, which you execute or it's just necessary pieces to show to us...

I ask this because it's compiles and runs here perfectly, but with little correction: this part is taken into a method:

Dime2 Dim3 = new Dime2();

            for (int j = 0; j < 1000; j++)
            {
                Dim3.Add(new Dime1());

                for (int i = 0; i < 1000; i++)
                {
                    Dim3[j].Add("0");
                }
            }

Yes that was true, I forgot to put the classes outside the event, so that was the problem.

Thank you for your time to check the code.

Hello, Darth Vader.

Just to make sure - is your code is a holistic part of code, which you execute or it's just necessary pieces to show to us...

I ask this because it's compiles and runs here perfectly, but with little correction: this part is taken into a method:

Dime2 Dim3 = new Dime2();

            for (int j = 0; j < 1000; j++)
            {
                Dim3.Add(new Dime1());

                for (int i = 0; i < 1000; i++)
                {
                    Dim3[j].Add("0");
                }
            }

You're welcome.
Good luck with your project :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.