System.Runtime.InteropServices.DllImportAttribute.CharSet Field

Indicates how to marshal string parameters to the method and controls name mangling.

Syntax

public CharSet CharSet

Remarks

Use this field with a member of the System.Runtime.InteropServices.CharSet enumeration to specify the marshaling behavior of string parameters and to specify which entry-point name to invoke (the exact name given or a name ending with "A" or "W"). The default enumeration member for C# and Visual Basic is CharSet.Ansi and the default enumeration member for C++ is CharSet.None, which is equivalent to CharSet.Ansi. In Visual Basic, you use the Declare statement to specify the CharSet field.

The DllImportAttribute.ExactSpelling field influences the behavior of the CharSet field in determining which entry-point name to invoke. For a detailed description and examples of the string marshaling and name matching behavior associated with the CharSet field, see Specifying a Character Set.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0