COM Data Types

The following table shows data types used in COM and their corresponding .NET Framework built-in value types or classes. Any type not explicitly identified in this table is converted to an Int32 system type. For corresponding types in Visual Basic 2005, C#, and C++, see the Introduction to the .NET Framework Class Library.

COM value type

COM reference type

System type

bool

bool *

System.Int32

char, small

char *, small *

System.SByte

short

short *

System.Int16

long, int

long *, int *

System.Int32

Hyper

hyper *

System.Int64

unsigned char, byte

unsigned char *, byte *

System.Byte

wchar_t, unsigned short

wchar_t *, unsigned short *

System.UInt16

unsigned long, unsigned int

unsigned long *, unsigned int *

System.UInt32

unsigned hyper

unsigned hyper *

System.UInt64

float

float *

System.Single

double

double *

System.Double

VARIANT_BOOL

VARIANT_BOOL *

System.Boolean

void *

void **

System.IntPtr

HRESULT

HRESULT *

System.Int16 or System.IntPtr

SCODE

SCODE *

System.Int32

BSTR

BSTR *

System.String

LPSTR or [string, …] char *

LPSTR *

System.String

LPWSTR or [string, …] wchar_t *

LPWSTR *

System.String

VARIANT

VARIANT *

System.Object

DECIMAL

DECIMAL *

System.Decimal

DATE

DATE *

System.DateTime

GUID

GUID *

System.Guid

CURRENCY

CURRENCY *

System.Decimal

IUnknown *

IUnknown **

System.Object

IDispatch *

IDispatch **

System.Object

SAFEARRAY( type )

SAFEARRAY( type ) *

type []

The following table lists COM value and reference types that convert to corresponding element types. For example, a COM coclass automatically maps to a managed class with the same name.

COM value type

COM reference type

Element type

Typedef BaseType MyType

ByRef BaseType

BaseType

MyStruct

ByRef VALUETYPE<MyStruct>

valuetype<MyStruct>

MyEnum

ByRef VALUETYPE<MyEnum>

valuetype<MyEnum>

MyInterface *

ByRef CLASS <MyInterface>

Class <MyInterface>

MyCoClass

ByRef CLASS <_Class>

Class <_Class>

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft