G
Greg Myers
Hello, I'm a noob to C# programming and was wondering if there was a
way around a problem I'm having. The following code snippet shows the
problem:
public class MyType<T> where T:struct
{
unsafe private T* mVar;
unsafe public MyType( ref T var )
{
fixed( T* address = &var )
{
mVar = address;
}
}
}
The compiler complains that I "Cannot take the address of, get the
size of, or declare a pointer to a managed type ('T')" even though my
where clause specifies that T must be a basic type. Is there a way
around this or do I just need to change my design? Thanks in advance
for any info provided.
Greg
way around a problem I'm having. The following code snippet shows the
problem:
public class MyType<T> where T:struct
{
unsafe private T* mVar;
unsafe public MyType( ref T var )
{
fixed( T* address = &var )
{
mVar = address;
}
}
}
The compiler complains that I "Cannot take the address of, get the
size of, or declare a pointer to a managed type ('T')" even though my
where clause specifies that T must be a basic type. Is there a way
around this or do I just need to change my design? Thanks in advance
for any info provided.
Greg