Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# Resize An Array
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01326722
Message ID:
01326750
Views:
12
>I wrote this code to store info coming from a text file. Each value in the txt file becomes an element in the array.
>
>
>Now I want to resize the array to be 2 dimensional, so I can insert another value describing each existing array element.
>
>Can someone show me how to do this please?

This doesn't directly answer your question, but I hope it helps anyway. I'd suggest not doing it this way. I would instead create a new class which has properties for the line, and any other properties you need for the additional info. you want to add. ex.
public class SampleItem
{
   private string m_line;  
   private string m_somethingElse;

   public Line
   {
      get { return this.m_line; }
      set { this.m_line = value; }
   }

   public SomethingElse
   {
      get { return this.m_somethingElse; }
      set { this.m_somethingElse = value; }
   }
   
   public SampleItem(string line)
   {
      this.m_line = line;
      this.m_somethingElse = "";
   }

   public SampleItem(string line, string somethingElse)
   {
      this.m_line = line;
      this.m_somethingElse = somethingElse);
   }
}
Then instead of:

aWords.Add(sWord);

Do something like:

aWords.Add(new SampleItem(sWord));

This makes things simpler and gives you a bunch of flexibility later (if you decide that you suddenly need more info. attached to this line, for example). Converting to a multidimensional array didn't look particularly straightforward.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform