FileRecordSequence.BaseSequenceNumber 属性

定义

获取当前 FileRecordSequence 中第一条有效记录的序列号。

public:
 property System::IO::Log::SequenceNumber BaseSequenceNumber { System::IO::Log::SequenceNumber get(); };
public System.IO.Log.SequenceNumber BaseSequenceNumber { get; }
member this.BaseSequenceNumber : System.IO.Log.SequenceNumber
Public ReadOnly Property BaseSequenceNumber As SequenceNumber

属性值

FileRecordSequence 中的有效记录对应的最低序列号。

实现

例外

该属性是在序列已释放之后访问的。

示例

下面的示例演示如何在循环中使用 BaseSequenceNumber

// Read the records added to the log.
    public void ReadRecords()
    {
        Encoding enc = Encoding.Unicode;

        Console.WriteLine();

        Console.WriteLine("Reading Log Records...");
        try
        {
            foreach (LogRecord record in this.sequence.ReadLogRecords(this.sequence.BaseSequenceNumber, LogRecordEnumeratorType.Next))
            {
                byte[] data = new byte[record.Data.Length];
                record.Data.Read(data, 0, (int)record.Data.Length);
                string mystr = enc.GetString(data);
                Console.WriteLine("    {0}", mystr);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception {0} {1}", e.GetType(), e.Message);
        }

        Console.WriteLine();
    }
' Read the records added to the log. 
    Public Sub ReadRecords()
        Dim enc As Encoding = Encoding.Unicode

        Console.WriteLine()

        Console.WriteLine("Reading Log Records...")
        Try
            For Each record In Me.sequence.ReadLogRecords(Me.sequence.BaseSequenceNumber, LogRecordEnumeratorType.Next)
                Dim data(record.Data.Length - 1) As Byte
                record.Data.Read(data, 0, CInt(Fix(record.Data.Length)))
                Dim mystr As String = enc.GetString(data)
                Console.WriteLine("    {0}", mystr)
            Next record
        Catch e As Exception
            Console.WriteLine("Exception {0} {1}", e.GetType(), e.Message)
        End Try

        Console.WriteLine()
    End Sub

注解

有效序列号大于或等于 BaseSequenceNumber 且小于 LastSequenceNumber。 所有其他序列号均无效。

此属性的值可以通过调用 WriteRestartAreaAdvanceBaseSequenceNumber 方法来更改。

适用于