Encoding.GetByteCount Method (Char*, Int32)
Assembly: mscorlib (in mscorlib.dll)
[CLSCompliantAttribute(false)] [ComVisibleAttribute(false)] public: virtual int GetByteCount ( wchar_t* chars, int count )
Not applicable.
Parameters
- chars
A pointer to the first character to encode.
- count
The number of characters to encode.
Return Value
The number of bytes produced by encoding the specified characters.| Exception type | Condition |
|---|---|
| chars is a null reference (Nothing in Visual Basic). | |
| count is less than zero. | |
| A fallback occurred (see Understanding Encodings for complete explanation) -and- EncoderFallback is set to EncoderExceptionFallback. |
To calculate the exact array size that GetBytes requires to store the resulting bytes, the application should use GetByteCount. To calculate the maximum array size, the application should use GetMaxByteCount. The GetByteCount method generally allows allocation of less memory, while the GetMaxByteCount method generally executes faster.
For a discussion of programming considerations for use of this method, see the Encoding class description.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.