Buffer クラス
アセンブリ: mscorlib (mscorlib.dll 内)


Buffer はプリミティブ型の配列だけに使用できます。オブジェクトの配列には使用できません。各プリミティブ型は、そのプリミティブ型に対応する動作や制限に関係なく、連続したバイト列として扱われます。
Buffer には、あるプリミティブ型の配列から別のプリミティブ型の配列にバイト列をコピーするメソッド、配列からバイトを取得するメソッド、配列にバイトを設定するメソッド、および配列の長さを取得するメソッドが用意されています。このクラスを使用すると、プリミティブ型の操作に対して、System.Array クラスの同様のメソッドより優れたパフォーマンスが得られます。
Buffer は、Boolean、Char、SByte、Byte、Int16、UInt16、Int32、UInt32、Int64、UInt64、IntPtr、UIntPtr、Single、および Double の各プリミティブ型に適用されます。

Buffer クラスの一部のメソッドの使用方法を次のコード例に示します。
' Example of the Buffer class methods. Imports System Imports Microsoft.VisualBasic Module BufferClassDemo ' Display the array elements from right to left in hexadecimal. Sub DisplayArray( arr( ) As Short ) Console.Write( " arr:" ) Dim loopX As Integer For loopX = arr.Length - 1 To 0 Step -1 Console.Write( " {0:X4}", arr( loopX ) ) Next loopX Console.WriteLine( ) End Sub Sub Main( ) ' This array is to be modified and displayed. Dim arr( ) As Short = { 258, 259, 260, 261, 262, 263, 264, _ 265, 266, 267, 268, 269, 270, 271 } Console.WriteLine( _ "This example of the Buffer class methods generates " & _ "the following output." & vbCrLf & "Note: The " & _ "array is displayed from right to left." & vbCrLf ) Console.WriteLine( "Initial values of array:" & vbCrLf ) ' Display the initial array values and ByteLength. DisplayArray( arr ) Console.WriteLine( vbCrLf & _ "Buffer.ByteLength( arr ): {0}", _ Buffer.ByteLength( arr ) ) ' Copy a region of the array; set a byte within the array. Console.WriteLine( vbCrLf & _ "Call these methods: " & vbCrLf & _ " Buffer.BlockCopy( arr, 5, arr, 16, 9 )," & vbCrLf & _ " Buffer.SetByte( arr, 7, 170 )." & vbCrLf ) Buffer.BlockCopy( arr, 5, arr, 16, 9 ) Buffer.SetByte( arr, 7, 170 ) ' Display the array and a byte within the array. Console.WriteLine( "Final values of array:" & vbCrLf ) DisplayArray( arr ) Console.WriteLine( vbCrLf & _ "Buffer.GetByte( arr, 26 ): {0}", _ Buffer.GetByte( arr, 26 ) ) End Sub End Module ' This example of the Buffer class methods generates the following output. ' Note: The array is displayed from right to left. ' ' Initial values of array: ' ' arr: 010F 010E 010D 010C 010B 010A 0109 0108 0107 0106 0105 0104 0103 0102 ' ' Buffer.ByteLength( arr ): 28 ' ' Call these methods: ' Buffer.BlockCopy( arr, 5, arr, 16, 9 ), ' Buffer.SetByte( arr, 7, 170 ). ' ' Final values of array: ' ' arr: 010F 0101 0801 0701 0601 0501 0109 0108 0107 0106 AA05 0104 0103 0102 ' ' Buffer.GetByte( arr, 26 ): 15
// Example of the Buffer class methods. using System; class BufferClassDemo { // Display the array elements from right to left in hexadecimal. public static void DisplayArray( short[ ] arr ) { Console.Write( " arr:" ); for( int loopX = arr.Length - 1; loopX >= 0; loopX-- ) Console.Write( " {0:X4}", arr[ loopX ] ); Console.WriteLine( ); } public static void Main( ) { // This array is to be modified and displayed. short[ ] arr = { 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271 }; Console.WriteLine( "This example of the Buffer class " + "methods generates the following output.\n" + "Note: The array is displayed from right to left.\n" ); Console.WriteLine( "Initial values of array:\n" ); // Display the initial array values and ByteLength. DisplayArray( arr ); Console.WriteLine( "\nBuffer.ByteLength( arr ): {0}", Buffer.ByteLength( arr ) ); // Copy a region of the array; set a byte within the array. Console.WriteLine( "\nCall these methods: \n" + " Buffer.BlockCopy( arr, 5, arr, 16, 9 ),\n" + " Buffer.SetByte( arr, 7, 170 ).\n" ); Buffer.BlockCopy( arr, 5, arr, 16, 9 ); Buffer.SetByte( arr, 7, 170 ); // Display the array and a byte within the array. Console.WriteLine( "Final values of array:\n" ); DisplayArray( arr ); Console.WriteLine( "\nBuffer.GetByte( arr, 26 ): {0}", Buffer.GetByte( arr, 26 ) ); } } /* This example of the Buffer class methods generates the following output. Note: The array is displayed from right to left. Initial values of array: arr: 010F 010E 010D 010C 010B 010A 0109 0108 0107 0106 0105 0104 0103 0102 Buffer.ByteLength( arr ): 28 Call these methods: Buffer.BlockCopy( arr, 5, arr, 16, 9 ), Buffer.SetByte( arr, 7, 170 ). Final values of array: arr: 010F 0101 0801 0701 0601 0501 0109 0108 0107 0106 AA05 0104 0103 0102 Buffer.GetByte( arr, 26 ): 15 */
// Example of the Buffer class methods. using namespace System; // Display the array elements from right to left in hexadecimal. void DisplayArray( array<short>^arr ) { Console::Write( " arr:" ); for ( int loopX = arr->Length - 1; loopX >= 0; loopX-- ) Console::Write( " {0:X4}", arr[ loopX ] ); Console::WriteLine(); } int main() { // This array is to be modified and displayed. array<short>^arr = {258,259,260,261,262,263,264,265,266,267,268,269,270 ,271}; Console::WriteLine( "This example of the Buffer class " "methods generates the following output.\n" "Note: The array is displayed from right to left.\n" ); Console::WriteLine( "Initial values of array:\n" ); // Display the initial array values and ByteLength. DisplayArray( arr ); Console::WriteLine( "\nBuffer::ByteLength( arr ): {0}", Buffer::ByteLength( arr ) ); // Copy a region of the array; set a byte within the array. Console::WriteLine( "\nCall these methods: \n" " Buffer::BlockCopy( arr, 5, arr, 16, 9 ),\n" " Buffer::SetByte( arr, 7, 170 ).\n" ); Buffer::BlockCopy( arr, 5, arr, 16, 9 ); Buffer::SetByte( arr, 7, 170 ); // Display the array and a byte within the array. Console::WriteLine( "Final values of array:\n" ); DisplayArray( arr ); Console::WriteLine( "\nBuffer::GetByte( arr, 26 ): {0}", Buffer::GetByte( arr, 26 ) ); } /* This example of the Buffer class methods generates the following output. Note: The array is displayed from right to left. Initial values of array: arr: 010F 010E 010D 010C 010B 010A 0109 0108 0107 0106 0105 0104 0103 0102 Buffer::ByteLength( arr ): 28 Call these methods: Buffer::BlockCopy( arr, 5, arr, 16, 9 ), Buffer::SetByte( arr, 7, 170 ). Final values of array: arr: 010F 0101 0801 0701 0601 0501 0109 0108 0107 0106 AA05 0104 0103 0102 Buffer::GetByte( arr, 26 ): 15 */
// Example of the Buffer class methods. import System.*; class BufferClassDemo { // Display the array elements from right to left in hexadecimal. public static void DisplayArray(short arr[]) { Console.Write(" arr:"); for (int loopX = arr.get_Length() - 1; loopX >= 0; loopX--) { Console.Write(" {0:X4}", arr.get_Item(loopX)); } Console.WriteLine(); } //DisplayArray public static void main(String[] args) { // This array is to be modified and displayed. short arr[] = { 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271 }; Console.WriteLine(("This example of the Buffer class " + "methods generates the following output.\n" + "Note: The array is displayed from right to left.\n")); Console.WriteLine("Initial values of array:\n"); // Display the initial array values and ByteLength. DisplayArray(arr); Console.WriteLine("\nBuffer.ByteLength( arr ): {0}", (Int32)Buffer.ByteLength(arr)); // Copy a region of the array; set a byte within the array. Console.WriteLine(("\nCall these methods: \n" + " Buffer.BlockCopy( arr, 5, arr, 16, 9 ),\n" + " Buffer.SetByte( arr, 7, 170 ).\n")); Buffer.BlockCopy(arr, 5, arr, 16, 9); Buffer.SetByte(arr, 7, (ubyte)(170)); // Display the array and a byte within the array. Console.WriteLine("Final values of array:\n"); DisplayArray(arr); Console.WriteLine("\nBuffer.GetByte( arr, 26 ): {0}", System.Convert.ToString(Buffer.GetByte(arr, 26))); } //main } //BufferClassDemo /* This example of the Buffer class methods generates the following output. Note: The array is displayed from right to left. Initial values of array: arr: 010F 010E 010D 010C 010B 010A 0109 0108 0107 0106 0105 0104 0103 0102 Buffer.ByteLength( arr ): 28 Call these methods: Buffer.BlockCopy( arr, 5, arr, 16, 9 ), Buffer.SetByte( arr, 7, 170 ). Final values of array: arr: 010F 0101 0801 0701 0601 0501 0109 0108 0107 0106 AA05 0104 0103 0102 Buffer.GetByte( arr, 26 ): 15 */

System.Buffer


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Buffer メソッド

名前 | 説明 | |
---|---|---|
![]() | BlockCopy | コピー先の配列の指定したオフセット位置を先頭として、コピー元の配列の指定したオフセットから指定数のバイトをコピーします。 |
![]() | ByteLength | 指定した配列のバイト数を返します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetByte | 指定した配列の指定した位置にあるバイトを取得します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | SetByte | 指定した配列の指定した位置にあるバイトに、指定した値を代入します。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

Buffer メンバ
Buffer データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | BlockCopy | コピー先の配列の指定したオフセット位置を先頭として、コピー元の配列の指定したオフセットから指定数のバイトをコピーします。 |
![]() | ByteLength | 指定した配列のバイト数を返します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetByte | 指定した配列の指定した位置にあるバイトを取得します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | SetByte | 指定した配列の指定した位置にあるバイトに、指定した値を代入します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

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

「buffer」に関係したコラム
FXのチャート分析ソフトMT4で高値と安値のラインを引くには
FX(外国為替証拠金取引)のチャート分析ソフトMT4(Meta Trader 4)で高値と安値のラインを引く方法を紹介します。高値のラインは、ローソクの高値の1本1本を線で結んだものになります。同じく...
-
FX(外国為替証拠金取引)のチャート分析ソフトMT4(Meta Trader 4)のインディケーターの作り方について解説します。インディケーターの作り方の大まかな流れは次の通りです。MetaEdito...
-
FX(外国為替証拠金取引)のチャート分析ソフトMT4(Meta Trader 4)で遅行線を表示する方法を紹介します。遅行線は、時間足の終値を指定した本数だけ左へずらしたものです。遅行スパンともいいま...
FXのチャート分析ソフトMT4のWilliams' Percent Rangeの見方
FX(外国為替証拠金取引)のチャート分析ソフトMT4(Meta Trader 4)のWilliams' Percent Rangeの見方を解説します。Williams' Percent Rangeは、...
- bufferのページへのリンク