Making an array of arrays

Total Post:39

 1663  View(s)
Rate this:
I need to implement an array of arrays which are Textbox so that I can reuse some of the code by being able to pass this array of arrays.

I have functions that take a Textbox as a parameter.
  1. Post:131

    Re: Making an array of arrays

    To declare an array of arrays (as opposed to a 2D array) in C# requires syntax such as the following. It's assumed that tbArray0 to tbArray15 are single dimensional arrays of length 16 though they can be of any length:

    TextBox[][] tbArrays = new TextBox[16][];
    tbArrays[0] = tbArray0;
    tbArrays[1] = tbArray1;
    tbArrays[15] = tbArray15;

    To pass such an array to a function requires a declaration such as:

    void SomeFunc(TextBox[][] tbArrays)

    The first element of the first array can then be accessed with the expression tbArray[0][0] and the last element of the last array with tbArray[15][15].

  1.   Modified On Mar-05-2011 02:57:14 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.