I
I
Ingvar Von Bjork2016-06-06 21:43:48
C++ / C#
Ingvar Von Bjork, 2016-06-06 21:43:48

How to increase the size of a 2D string array?

There is a two-dimensional array string t = new string[i, j]; it is required to increase the length of the array j by 1 during the function operation. How can this be done?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
GavriKos, 2016-06-06
@DeboshiR

The correct option is to use List. The
wrong option is to allocate memory for a new array with 1 more element and copy everything element by element.

V
Vitaly Pukhov, 2016-06-06
@Neuroware

Even more correct might be to use a list type like Queue or Stack

T
Tsiren Naimanov, 2016-06-07
@ImmortalCAT

GavriKos read the source code of IList, List, List
there is an array and goes

M
Mikhail Usotsky, 2016-06-08
@Aquarius-Michael

If you want this option: Array.Resize<int>(ref t, t.Length + 1);
I did it in my project. Later abandoned in favor of collections with modification.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question