Export (0) Print
Expand All

Encoding.GetCharCount Method (Byte*, Int32)

When overridden in a derived class, calculates the number of characters produced by decoding a sequence of bytes starting at the specified byte pointer.

This method is not CLS-compliant.  

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)

[ComVisibleAttribute(false)] 
[CLSCompliantAttribute(false)] 
public virtual int GetCharCount (
	byte* bytes,
	int count
)
Not applicable.

Parameters

bytes

A pointer to the first byte to decode.

count

The number of bytes to decode.

Return Value

The number of characters produced by decoding the specified sequence of bytes.

Exception typeCondition

ArgumentNullException

bytes is a null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

count is less than zero.

DecoderFallbackException

A fallback occurred (see Understanding Encodings for complete explanation)

-and-

DecoderFallback is set to DecoderExceptionFallback.

To calculate the exact array size that GetChars requires to store the resulting characters, the application should use GetCharCount. To calculate the maximum array size, the application should use GetMaxCharCount. The GetCharCount method generally allows allocation of less memory, while the GetMaxCharCount 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.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft