Buffer Buffer Buffer Buffer Class

정의

기본 형식의 배열을 조작합니다.Manipulates arrays of primitive types.

public ref class Buffer abstract sealed
[System.Runtime.InteropServices.ComVisible(true)]
public static class Buffer
type Buffer = class
Public Class Buffer
상속
BufferBufferBufferBuffer
특성

예제

다음 코드 예제에는 일부의 사용 방법을 보여 줍니다. Buffer 메서드 클래스입니다.The following code example illustrates the use of several Buffer class methods.

// 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.
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.
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

설명

Buffer 기본 형식의 배열에만 적용 이 클래스는 개체에는 적용 되지 않습니다.Buffer only affects arrays of primitive types; this class does not apply to objects. 각 기본 형식의 일련의 모든 동작 또는 기본 형식과 연결 된 제한에 관계 없이 바이트로 처리 됩니다.Each primitive type is treated as a series of bytes without regard to any behavior or limitation associated with the primitive type.

Buffer 배열에서 바이트를 가져오기, 바이트 배열에 있는 설정 및 배열의 길이 가져오려면 배열을 다른 기본 형식과 기본 형식의 배열 바이트를 복사 하는 방법 제공 합니다.Buffer provides methods to copy bytes from one array of primitive types to another array of primitive types, get a byte from an array, set a byte in an array, and obtain the length of an array. 이 클래스는 기본 형식에서 이와 유사한 메서드를 조작 하기 위한 더 나은 성능을 제공 합니다 System.Array 클래스입니다.This class provides better performance for manipulating primitive types than similar methods in the System.Array class.

Buffer 기본 형식에 적용 됩니다: Boolean, Char, SByte, Byte, Int16UInt16, Int32UInt32, Int64UInt64, IntPtr, UIntPtr하십시오 Single, 및 Double합니다.Buffer is applicable to the following primitive types: Boolean, Char, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Single, and Double.

메서드

BlockCopy(Array, Int32, Array, Int32, Int32) BlockCopy(Array, Int32, Array, Int32, Int32) BlockCopy(Array, Int32, Array, Int32, Int32) BlockCopy(Array, Int32, Array, Int32, Int32)

특정 오프셋에서 시작하는 소스 배열에서 특정 오프셋에서 시작하는 대상 배열로 지정된 바이트 수를 복사합니다.Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset.

ByteLength(Array) ByteLength(Array) ByteLength(Array) ByteLength(Array)

지정된 배열의 바이트 수를 반환합니다.Returns the number of bytes in the specified array.

GetByte(Array, Int32) GetByte(Array, Int32) GetByte(Array, Int32) GetByte(Array, Int32)

지정된 배열의 지정된 위치에 있는 바이트를 검색합니다.Retrieves the byte at the specified location in the specified array.

MemoryCopy(Void*, Void*, Int64, Int64) MemoryCopy(Void*, Void*, Int64, Int64) MemoryCopy(Void*, Void*, Int64, Int64) MemoryCopy(Void*, Void*, Int64, Int64)

메모리에 있는 하나의 주소에서 다른 주소에 정수(Long) 값으로 지정된 바이트 수를 복사합니다.Copies a number of bytes specified as a long integer value from one address in memory to another.

이 API는 CLS 규격이 아닙니다.This API is not CLS-compliant.

MemoryCopy(Void*, Void*, UInt64, UInt64) MemoryCopy(Void*, Void*, UInt64, UInt64) MemoryCopy(Void*, Void*, UInt64, UInt64) MemoryCopy(Void*, Void*, UInt64, UInt64)

메모리에 있는 하나의 주소에서 다른 주소에 부호 없는 정수(Long) 값으로 지정된 바이트 수를 복사합니다.Copies a number of bytes specified as an unsigned long integer value from one address in memory to another.

이 API는 CLS 규격이 아닙니다.This API is not CLS-compliant.

SetByte(Array, Int32, Byte) SetByte(Array, Int32, Byte) SetByte(Array, Int32, Byte) SetByte(Array, Int32, Byte)

지정된 배열의 특정 위치에 있는 바이트에 지정된 값을 할당합니다.Assigns a specified value to a byte at a particular location in a specified array.

적용 대상