Re: [ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-17 Thread Sébastien Lorion
It *could* be every type ... It happens it is pretty similar, I admit I did make a table like you did. Array.Copy seems to be as fast as Buffer.BlockCopy, but if anyone on this list has a different experience, please let me know. I know sizeof(T) could not work and I was writing that only to expr

Re: [ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-17 Thread Curt Hagenlocher
On Wed, Apr 16, 2008 at 10:10 PM, Sébastien Lorion <[EMAIL PROTECTED]> wrote: > On 4/17/08, Curt Hagenlocher <[EMAIL PROTECTED]> wrote: > > On Wed, Apr 16, 2008 at 8:31 PM, Sébastien Lorion > > > > <[EMAIL PROTECTED]> wrote: > > > > > I want the managed size, so Marshal.SizeOf does not return the c

Re: [ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-16 Thread Sébastien Lorion
On 4/17/08, Curt Hagenlocher <[EMAIL PROTECTED]> wrote: > On Wed, Apr 16, 2008 at 8:31 PM, Sébastien Lorion > > <[EMAIL PROTECTED]> wrote: > > > I want the managed size, so Marshal.SizeOf does not return the correct > > value. > > > > For example, sizeof(char) returns 2 and Marshal.SizeOf(typeof

Re: [ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-16 Thread Andrew Cherry
nced .NET topics. [mailto:ADVANCED- > [EMAIL PROTECTED] On Behalf Of Curt Hagenlocher > Sent: Wednesday, April 16, 2008 9:07 PM > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: Re: [ADVANCED-DOTNET] Getting managed size of a generic > parameter > > On Wed, Apr 16, 2008 at 8:31 PM,

Re: [ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-16 Thread Curt Hagenlocher
On Wed, Apr 16, 2008 at 8:31 PM, Sébastien Lorion <[EMAIL PROTECTED]> wrote: > 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. Huh. So it does. Are there any other types for which

Re: [ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-16 Thread Sébastien Lorion
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

Re: [ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-16 Thread Curt Hagenlocher
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, destina

[ADVANCED-DOTNET] Getting managed size of a generic parameter

2008-04-16 Thread Sébastien Lorion
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) Thanks, -- Sébastien www.sebastie