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(char)) > returns 1. > > > Huh. So it does. Are there any other types for which this is true? >
Well, basically every types ... Marshal.SizeOf returns the size of the equivalent unmanaged type. Another example would be boolean: Marshal returns 4 instead of 1. Just to restate my original problem clearly: I wanted to use Buffer.BlockCopy in a class with generic parameters and I could not use sizeof(T). I switched to Array.Copy instead, but I am still curious about how to find the size of a generic parameter. Sébastien =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com