IBinarySerialize.Read メソッド
アセンブリ: System.Data (system.data.dll 内)



以前に永続化した UDT を、BinaryReader を使用して逆シリアル化する Read メソッドの実装の例を次に示します。この例は、UDT が 2 つのデータ プロパティ StringValue と DoubleValue を持っていると仮定しています。
' The binary layout is as follows: ' Bytes 0 - 19: string text, padded to the right with null ' characters ' Bytes 20+: double value Public Sub Read(ByVal r As System.IO.BinaryReader) _ Implements Microsoft.SqlServer.Server.IBinarySerialize.Read Dim maxStringSize As Integer = 20 Dim chars As Char() Dim stringEnd As Integer Dim stringValue As String Dim value As double ' Read the characters from the binary stream. chars = r.ReadChars(maxStringSize) ' Find the start of the null character padding. stringEnd = Array.IndexOf(chars, ControlChars.NullChar) If StringEnd = 0 Then stringValue = Nothing Exit Sub End If ' Build the string from the array of characters. stringValue = new String(chars, 0, stringEnd) ' Read the double value from the binary stream. value = r.ReadDouble() ' Set the object's properties equal to the values. Me.StringValue = stringValue Me.DoubleValue = value End Sub
// The binary layout is as follows: // Bytes 0 - 19: string text, padded to the right with null characters // Bytes 20+: Double value public void Read(System.IO.BinaryReader r) { int maxStringSize = 20; char[] chars; int stringEnd; string stringValue; double doubleValue; // Read the characters from the binary stream. chars = r.ReadChars(maxStringSize); // Find the start of the null character padding. stringEnd = Array.IndexOf(chars, '\0'); if (stringEnd == 0) { stringValue = null; return; } // Build the string from the array of characters. stringValue = new String(chars, 0, stringEnd); // Read the double value from the binary stream. doubleValue = r.ReadDouble(); // Set the object's properties equal to the values. this.StringValue = stringValue; this.DoubleValue = doubleValue; }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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

- IBinarySerialize.Read メソッドのページへのリンク