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

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


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

次の例は、指定した文字数をエンコードするために必要な最大バイト数を、GetMaxByteCount メソッドを使用して計算する方法を示しています。
Imports System Imports System.Text Class UTF8EncodingExample Public Shared Sub Main() Dim utf8 As New UTF8Encoding() Dim charCount As Integer = 2 Dim maxByteCount As Integer = utf8.GetMaxByteCount(charCount) Console.WriteLine( _ "Maximum of {0} bytes needed to encode {1} characters.", _ maxByteCount, _ charCount _ ) End Sub 'Main End Class 'UTF8EncodingExample
using System; using System.Text; class UTF8EncodingExample { public static void Main() { UTF8Encoding utf8 = new UTF8Encoding(); int charCount = 2; int maxByteCount = utf8.GetMaxByteCount(charCount); Console.WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); } }
using namespace System; using namespace System::Text; int main() { UTF8Encoding^ utf8 = gcnew UTF8Encoding; int charCount = 2; int maxByteCount = utf8->GetMaxByteCount( charCount ); Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); }
import System.*; import System.Text.*; class UTF8EncodingExample { public static void main(String[] args) { UTF8Encoding utf8 = new UTF8Encoding(); int charCount = 2; int maxByteCount = utf8.GetMaxByteCount(charCount); Console.WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", String.valueOf(maxByteCount), String.valueOf(charCount)); } //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.GetMaxByteCount メソッドを検索する場合は、下記のリンクをクリックしてください。

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