Hi,
I have many suitable structures wich I need to handle in a binary fashion,
I can take the address of a struct inside unsafe and fixed block
and this works when the struct is pased as a ref parameter,
however if I use a template this breaks, despite restraining it to struct.
public void Copy(ref datahead_struct src)
{
unsafe
{
fixed (void* p = &src)
{
//...
}
}
}
public void Copy<T>(ref T src) where T:struct
{
unsafe
{
fixed (void* p = &src)
{
// ^ ...Error 1 Cannot take the address of, get the size of, or declare a
pointer to a managed type ('T')
}
}
}
I am wondering if this is because it cant know if the structure contains
managed object references,
however I dont want to copy and paste the same function for every struct
I have :s
any ideas how i can get the address of a struct that isnt insanly unsafe ?
I know there are methods wich involve quite a lot of copying but this is
precisly what im trying to avoid.
many thanks
Colin =^.^=