I would like to be able to declare a function as
void foo(<any value type>[] data){}
in C# 2.0. If I declare it as
void foo(ValueType[] data){}
it compiles, but then the elements in data[] are treated as though they're derived from object
, e.g. I can't say something like
fixed (void* pData = data){}
I'd like to avoid taking the void* as the parameter -- I just want to be able to accept any value-type array and then do unmanaged things to it.
ETA: Also, this has the same problem:
public static unsafe void foo<T>(T[] data) where T:struct{
fixed(void *p = data){}
}
in case you were wondering. Fixed fails because it's treated as a managed type -- CS0208, cannot declare a pointer to a managed type. See "mm" below. I think he's right... it probably just can't be done.