Type cast

  • Thread starter Thread starter Peter Larsen
  • Start date Start date
P

Peter Larsen

Hi,

How do i type cast a type to an array of type,
e.g. IntPtr to IntPtr[] ??

/Peter
 
You cannot simply turn a int into an array of ints, they are different
types.

You can add an int to an array of ints.

int[] manyInts = new int[] {myInt1, myInt2};
 
Ok, i think i have to explain this a little bit better :-)
IntPtr poins to an array of structs, chars, floats or other types.

E.g. in some languages, if you have a property s of the type string, you can
simply turn s into an array of chars, s[0].

Or in C++ you can do something like this:

struct MyStruct
int count;
int i[1];
}

MyStruct ms = (MyStruct)myProperty.
ms->i[count-1] etc.etc.

/Peter

Peter Rilling said:
You cannot simply turn a int into an array of ints, they are different
types.

You can add an int to an array of ints.

int[] manyInts = new int[] {myInt1, myInt2};

Peter Larsen said:
Hi,

How do i type cast a type to an array of type,
e.g. IntPtr to IntPtr[] ??

/Peter
 
Back
Top