G
Guest
Hello
I'd like to write a Generic class that use a pointer to the generic structure.
I can't do this
unsafe public class PClass<S> where S : new()
{
public S* pData;
public PClass( )
{
pData = (S*) .....
}
}
Nor
public class PClass<S> where S : new()
{
unsafe public void Pippo( )
{
S myS = new S();
fixed (S* pSClass = &myS )
{
..............
}
}
}
While I can do this having defined MyStruct
unsafe public class PClass()
{
public void* pData;
public MyStruct* pData2;
public PClass( )
{
pData= (void*) .....
pData2= (MyStruct*) .....
}
unsafe public void Pippo( )
{
float[] myS = new float[100];
fixed (float* pSClass = &myS )
{
..............
}
}
}
HOW COME THE GENERIC VERSION IS NOT ALLOWED ?
I REALLY CAN'T FIGURE IT OUT.
Many thanks
I'd like to write a Generic class that use a pointer to the generic structure.
I can't do this
unsafe public class PClass<S> where S : new()
{
public S* pData;
public PClass( )
{
pData = (S*) .....
}
}
Nor
public class PClass<S> where S : new()
{
unsafe public void Pippo( )
{
S myS = new S();
fixed (S* pSClass = &myS )
{
..............
}
}
}
While I can do this having defined MyStruct
unsafe public class PClass()
{
public void* pData;
public MyStruct* pData2;
public PClass( )
{
pData= (void*) .....
pData2= (MyStruct*) .....
}
unsafe public void Pippo( )
{
float[] myS = new float[100];
fixed (float* pSClass = &myS )
{
..............
}
}
}
HOW COME THE GENERIC VERSION IS NOT ALLOWED ?
I REALLY CAN'T FIGURE IT OUT.
Many thanks