This documentation is archived and is not being maintained.

StructLayoutAttribute.CharSet Field

Indicates how string data fields within the class should be marshaled as LPWSTR or LPSTR by default.

[Visual Basic]
Public CharSet As CharSet
public CharSet CharSet;
public: CharSet CharSet;
public var CharSet : CharSet;


If the CharSet field is set to CharSet.Unicode, all string arguments are converted to Unicode characters (LPWSTR) before being passed to the unmanaged implementation. If the field is set to CharSet.Ansi, the strings are converted to ANSI strings (LPSTR). If the CharSet field is set to CharSet.Auto, the conversion is platform dependent (Unicode on Windows NT, Windows 2000, Windows XP, and Windows Server 2003 family; ANSI on Windows 98 and Windows Me).


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

StructLayoutAttribute Class | StructLayoutAttribute Members | System.Runtime.InteropServices Namespace