×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Alternative to 2-dimension array that needs to get larger?

Alternative to 2-dimension array that needs to get larger?

Alternative to 2-dimension array that needs to get larger?

(OP)
Hi Folks

OK so I'm working on an application where I move data around from one text box to another, and part of what I need to do is keep a record of what data moved from one TextBox to the other.

Since I come from a VB background I figured I would just create a 2-dimensional array and store the Data Text, Starting Box and Ending box as such: X,0 = Data Text, X,1 = Starting Box, X,2 = Ending box where X is the first dimension of the array. To add 'records' I would just ReDim the array and add onto it.

But as I've recently learned you cannot easily (if at all) redimension a multidimensional array in C#. I could simply declare that array to hold the maximum number of possible moves and just deal with the memory overhead, but I'd rather learn something.

I thought about trying to use the ListOf<I> collection but this does not seem to allow more than one value per line. Likewise a Hash Table is just a key/value type of thing.

Any thoughts on what I could do with this? I suppose I could just use a hashtable with one string per unique key that has comma-separated values for the rest of the data, but is there another better option I have not yet discovered?

Thanks

Craig

RE: Alternative to 2-dimension array that needs to get larger?

A list is just a list of objects be those objects simple or complex. How about a basic class to maintain your manipulated/moved data and a collection of those as a list?

Sorry, c#...

CODE

public class Dummy
{
	public int Id { get; set; }
	public string TextContent { get; set; }
	public TextBox SourceControl { get; set; }	// This could just as easily be a string of the Source Control Id
	public TextBox DestinationControl { get; set; }	// This could just as easily be a string of the Source Control Id	
} 

ListOf<Dummy>

Rhys

"Technological progress is like an axe in the hands of a pathological criminal"
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"
Albert Einstein

RE: Alternative to 2-dimension array that needs to get larger?

As a predominately VB programmer, I rarely use ReDim or ReDim Preserve and use methods similar to Rhys's suggestion. In this case a class to hold the source and destination objects with other info as appropriate and each instance of the class stored in a List.

RE: Alternative to 2-dimension array that needs to get larger?

(OP)
Thanks Rhys,

I jad actually started out by trying to define a class as you suggested but I hadn't put together being able to use the ListOf collection like that. I should have seen that myself. Thanks for the slap to the head!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close