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

Name

Marshal

Synopsis

This class offers a collection of static methods for working with unmanaged memory and converting managed types to unmanaged types. Unless you are developing specialized code for marshaling types between managed and unmanaged code, you probably do not need to use any of these methods.

GetHRForException( ) converts a .NET exception to a COM HResult. If you are curious about the platform you are running on, you can find out the size of a character with the SystemDefaultCharSize field, which is 1 on an ANSI platform (Windows 9x/Me) and 2 on a Unicode platform (Windows NT, 2000, and XP).

Use the IsComObject( ) method to determine whether an object is actually an unmanaged COM object. The AddRef( ) method increments a COM object’s reference count.

public sealed class Marshal {
// Public Static Fields
   public static readonly int SystemDefaultCharSize;  
// =2
   public static readonly int SystemMaxDBCSCharSize;  
// =1
                  // Public Static Methods
   public static int AddRef(IntPtr pUnk);
   public static IntPtr AllocCoTaskMem(int cb);
   public static IntPtr AllocHGlobal(int cb);
   public static IntPtr AllocHGlobal(IntPtr cb);
   public static object BindToMoniker(string monikerName);
   public static void ChangeWrapperHandleStrength(object otp, bool fIsWeak);
   public static void Copy(byte[ ] source, int startIndex, IntPtr destination, int length);
   public static void Copy(char[ ] source, int startIndex, IntPtr destination, int length);
   public static void Copy(double[ ] source, int startIndex
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