I want the managed size, so Marshal.SizeOf does not return the correct value.
For example, sizeof(char) returns 2 and Marshal.SizeOf(typeof(char)) returns 1. Sébastien On 4/16/08, Curt Hagenlocher <[EMAIL PROTECTED]> wrote: > On Wed, Apr 16, 2008 at 5:26 PM, Sébastien Lorion > <[EMAIL PROTECTED]> wrote: > > Is there a way to know the managed size of a type parameter at runtime > > ? What I want to do is something like: > > > > int typeSize = sizeof(T); // pseudo-code > > > > Buffer.BlockCopy(source, sourceIndex * typeSize, destination, > > destinationIndex * typeSize, length * typeSize) > > > Presumably, T is something marshal-friendly or you're in a state of > sin already. As such, you should be able to say > Marshal.SizeOf(typeof(T)); > > > -- > Curt Hagenlocher > [EMAIL PROTECTED] > > =================================== > This list is hosted by DevelopMentor(R) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > -- Sébastien www.sebastienlorion.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com