Redimension an array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings to all, i need to create a matrix (or something that make the job)
to store 3 values per row to insert everything (there will be several rows)
later in my database but i can´t find a way to do it, any help can be usefull.

Thank you in advance.
 
Well, you can use a DataTable that directly represents the table of the
database, which will allow for easier insertion. Or you can just use
an array of arrays... or a multidimensional array (see
http://www.c-sharpcorner.com/Code/2002/July/WorkingWithArrays.asp).
Any number of options. Probably the best approach would be to work
with DataSets/DataTables, since that way you can even validate that
your database won't choke on the data the moment you insert into the
collection, instead of waiting until you try to reach the DB... but
that's also the most complex. Probably the bext approach for you would
be a list of arrays - IE:

List<string[]> myList = new List<string[]>();

Wherein you can just insert using something like
List.Append(new string[]{firstval, secondval, thirdval});

or somesuch nonsense.
 
Maybe try using a generic List of string arrays, like this:

List<string[]> myList = new List<string[]>();
myList.Add(new string[] {"woo", "yay", "hoopla"});
 
I was trying to use a datatable, but everytime i click the ok button, it was
in 0 cols and rows, i was trying to set all the values before saving. but i
can't figure it out how to keep all my values.
 
Back
Top