SizeOf(T) Method
Collapse the table of content
Expand the table of content

Marshal.SizeOf<T> Method ()


[Supported in the .NET Framework 4.5.1 and later versions]

Returns the size of an unmanaged type in bytes.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

public static int SizeOf<T>()

Return Value

Type: System.Int32

The size, in bytes, of the type that is specified by the T generic type parameter.

Type Parameters


The type whose size is to be returned.

You can use this method when you do not have a structure. The layout must be sequential or explicit.

The size returned is the size of the unmanaged type. The unmanaged and managed sizes of an object can differ. For character types, the size is affected by the CharSet value applied to that class.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.5.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft