Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

Appendix C. Data Marshaling

When calling between the runtime environment and existing COM interfaces, the CLR performs automatic data marshaling for CLR types into compatible COM types. Table C-1 describes the C# to COM default data type mapping.

Table C-1. C# type to COM type mapping

C# type

COM type

bool

VARIANT_BOOL

char

unsigned short

sbyte

Char

byte

Unsigned char

short

Short

ushort

Unsigned short

int

Int

uint

Unsigned int

long

Hyper

ulong

Unsigned hyper

float

Single

double

Double

decimal

DECIMAL

object

VARIANT

string

BSTR

System.DateTime

DATE [a]

System.Guid

GUID

System.Currency

CURRENCY

1-dimensional arrays

SAFEARRAY

Value types

Equivalently named struct

enum

Equivalently named enum

interface

Equivalently named interface

class

Equivalently named CoClass

[a] COM dates are less precise, causing comparison problems.

Table C-2. C# modifier/COM attribute mapping

C# modifier

COM attribute

<no modifier>

[in]

out

[out]

ref

[in, out]

<return value>

[out, retval]

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard

Publisher Resources

ISBN: 0596005261Catalog PageErrata