UTF8Encoding.GetMaxCharCount メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As UTF8Encoding Dim byteCount As Integer Dim returnValue As Integer returnValue = instance.GetMaxCharCount(byteCount)
戻り値
指定したバイト数をデコードすることによって生成される最大文字数。


GetChars が生成した文字を格納するために必要な正確な配列サイズを計算するには、GetCharCount を使用します。最大配列サイズを計算するには、GetMaxCharCount を使用します。通常、GetMaxCharCount メソッドの方が高速に実行されるのに対し、GetCharCount メソッドの方が使用メモリが少なくて済みます。

次の例は、指定したバイト数をデコードすることによって生成される最大文字数を、GetMaxCharCount メソッドを使用して計算する方法を示しています。
Imports System Imports System.Text Class UTF8EncodingExample Public Shared Sub Main() Dim utf8 As New UTF8Encoding() Dim byteCount As Integer = 8 Dim maxCharCount As Integer = utf8.GetMaxCharCount(byteCount) Console.WriteLine( _ "Maximum of {0} characters needed to decode {1} bytes.", _ maxCharCount, _ byteCount _ ) End Sub 'Main End Class 'UTF8EncodingExample
using System; using System.Text; class UTF8EncodingExample { public static void Main() { UTF8Encoding utf8 = new UTF8Encoding(); int byteCount = 8; int maxCharCount = utf8.GetMaxCharCount(byteCount); Console.WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); } }
using namespace System; using namespace System::Text; int main() { UTF8Encoding^ utf8 = gcnew UTF8Encoding; int byteCount = 8; int maxCharCount = utf8->GetMaxCharCount( byteCount ); Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); }
import System.*; import System.Text.*; class UTF8EncodingExample { public static void main(String[] args) { UTF8Encoding utf8 = new UTF8Encoding(); int byteCount = 8; int maxCharCount = utf8.GetMaxCharCount(byteCount); Console.WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", String.valueOf(maxCharCount), String.valueOf(byteCount)); } //main } //UTF8EncodingExample

Windows 98, Windows 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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からUTF8Encoding.GetMaxCharCount メソッドを検索する場合は、下記のリンクをクリックしてください。

- UTF8Encoding.GetMaxCharCount メソッドのページへのリンク