O'Reilly logo

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

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

MarshalAsAttribute

Synopsis

This optional attribute is used to explicitly specify the unmanaged type a parameter, field, or return value should be marshaled to. If you do not specify this attribute, .NET uses the type’s default marshaler. The UnmanagedType enumeration contains the unmanaged types you can marshal to with this attribute.

public sealed class MarshalAsAttribute : Attribute {
// Public Constructors
   public method MarshalAsAttribute(short unmanagedType);  
   public method MarshalAsAttribute(
        UnmanagedType unmanagedType);  
// Public Instance Fields
   public field UnmanagedType ArraySubType;  
   public field string MarshalCookie;  
   public field string MarshalType;  
   public field Type MarshalTypeRef;  
   public field VarEnum SafeArraySubType;  
   public field Type SafeArrayUserDefinedSubType;  
   public field int SizeConst;  
   public field short SizeParamIndex;  
// Public Instance Properties
   public field UnmanagedType Value{get; } 
}

Hierarchy

System.ObjectSystem.AttributeMarshalAsAttribute

Valid On

Field, Parameter, ReturnValue

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required