Encoding::GetByteCount Method (String)
When overridden in a derived class, calculates the number of bytes produced by encoding the characters in the specified string.
Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Parameters
- s
- Type: System::String
The string that contains the set of characters to encode.
| Exception | Condition |
|---|---|
| ArgumentNullException | s is nullptr. |
| EncoderFallbackException | A fallback occurred (see Understanding Encodings for complete explanation). |
To calculate the exact array size required by GetBytes 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 allocates 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.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.