Print an array to the debug windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Roberts

    Print an array to the debug windows

    In VB6 I have a routine that accepts a 2D array and prints it to the debug
    windows. The array can be of any type (eg integer, string, double etc)....

    Public Sub DPArray(ArrayTo Print As Variant)
    Dim zz As Integer, xx As Integer
    For zz = 1 To UBound(ArrayToP rint, 1)
    For xx = 1 To UBound(ArrayToP rint, 2)
    Debug.Print ArrayToPrint(zz , xx);
    Next xx
    Debug.Print
    Next zz
    Debug.Print
    End Sub

    How can I translate this to Csharp? I have tried the following but get an
    "Cannot apply indexing with [] to an expression of type 'System.Array'"
    error.

    public static void DPArray(Array ArrayToPrint)
    {
    for (int zz = 0; zz < ArrayToPrint.Ge tUpperBound(0); zz++)
    {
    for (int xx = 0; xx < ArrayToPrint.Ge tUpperBound(1); xx++)
    {
    Debug.WriteLine (ArrayToPrint[zz, xx]);
    }
    Debug.WriteLine ("");
    }
    Debug.WriteLine ("");
    }


    Thanks

    Alan


Working...