Changind array dimension

  • Thread starter Thread starter Luigi
  • Start date Start date
Vadym Stetsiak said:
Hello, Luigi!

Array has Resize method. Is that suitable for you?
Yes, like this:

string[] myArray = new string[4]{"Primo", "Secondo", "Terzo", "Quarto"};

Array.Resize(ref myArray, 2);

Thanks Vadym.

Luigi
 
To be clear, you are talking about the *size* of an array, not the dimension.
Dimension means something else for arrays (i.e., 1 dimension is more common,
2 dimension is a rectangular array, etc.). You can't change an array's
dimension - a 1 dimensional array cannot be changed to a 2 dimensional array.

The use of "dimension" when talking about array size is probably due to VB's
unfortunate use of "ReDim" (short for re-dimension, but actually used for
re-sizing), and this improper keyword naming is still inflicted on the
current generation of VB programmers ;)
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++ VB Edition: VB to C++/CLI
Instant C++ C# Edition: C# to C++/CLI
 
Wow - I just noticed that the C# debugger also calls array sizes "dimensions"
- I can't believe that this hasn't been corrected.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++ VB Edition: VB to C++/CLI
Instant C++ C# Edition: C# to C++/CLI
 
Back
Top