Unsafe pointer

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

    #1

    Unsafe pointer

    Hi,

    please could someone show me how to access a two dimensional array using
    unsafe pointers? My C code won't work in C# :-( I used:

    arr[2][1] is equivalent to:

    *(*(arr+2)+1);

    what am I doing wrong?

  • Benny Mathew

    #2
    Re: Unsafe pointer

    Hi Sona,
    For multi-dimensional arrays, array elements are stored such that the
    indices of the rightmost dimension are increased first, then the next
    left dimension, and so on to the left.

    check this out:


    Cheers
    Benny

    Sona wrote:
    [color=blue]
    > Hi,
    >
    > please could someone show me how to access a two dimensional array using
    > unsafe pointers? My C code won't work in C# :-( I used:
    >
    > arr[2][1] is equivalent to:
    >
    > *(*(arr+2)+1);
    >
    > what am I doing wrong?
    >[/color]

    Comment

    Working...