IBinarySerialize.Write(BinaryWriter) 메서드

정의

UDT(사용자 정의 형식) 또는 사용자 정의 집계를 해당 이진 형식으로 변환하여 보관될 수 있도록 합니다.

public:
 void Write(System::IO::BinaryWriter ^ w);
public void Write (System.IO.BinaryWriter w);
abstract member Write : System.IO.BinaryWriter -> unit
Public Sub Write (w As BinaryWriter)

매개 변수

w
BinaryWriter

UDT 또는 사용자 정의 집계가 serialize되는 BinaryWriter 스트림입니다.

예제

다음 예제에서는 을 사용하여 BinaryWriter 사용자 정의 이진 형식으로 UDT를 직렬화하는 UDT의 메서드 구현 Write 을 보여 있습니다. null 문자 패딩의 목적은 문자열 값이 double 값과 완전히 분리되어 한 UDT가 Transact-SQL 코드의 다른 UDT와 비교되고 문자열 바이트가 문자열 바이트와 비교되고 더블 바이트가 더블 바이트와 비교되도록 하는 것입니다.

// The binary layout is as follows:
//    Bytes 0 - 19: string text, padded to the right with null characters
//    Bytes 20+: Double value

// using Microsoft.SqlServer.Server;
public void Write(System.IO.BinaryWriter w)
{
    int maxStringSize = 20;
    string stringValue = "The value of PI: ";
    string paddedString;
    double value = 3.14159;

    // Pad the string from the right with null characters.
    paddedString = stringValue.PadRight(maxStringSize, '\0');

    // Write the string value one byte at a time.
    for (int i = 0; i < paddedString.Length; i++)
    {
        w.Write(paddedString[i]);
    }

    // Write the double value.
    w.Write(value);
}

설명

메서드가 UDT 또는 사용자 정의 집계를 재구성할 수 있도록 Read 이진 스트림에 충분한 정보를 씁니다.

적용 대상