0

基本的に、次のコードを使用して、VB.NET でバイト配列を検索しています。

For i As Integer = 0 To message.Length - 1
    If message(i) = Asc(ControlChars.Cr) Then
        If message(i + 1) = Asc(ControlChars.Lf) Then
            If message(i + 2) = Asc(ControlChars.Cr) Then
                If message(i + 3) = Asc(ControlChars.Lf) Then
                    start = i + 4 ' take into account the above characters
                    Exit For
                End If
            End If
        End If
    End If
Next

Dim length As Integer = message.Length - start

これを行うためのより良い方法があるかどうか疑問に思っていましたか?私はこのようなことをしてみました:

start = message.IndexOf({ControlChars.CrLf, ControlChars.CrLf})

しかし、それは -1 を返します。

また、私がこれを持っているように、バイトの配列からバイトを取り除くより良い方法はありますか:

Dim text(message.Length - start) As Byte
Dim position As Integer = 0
For i As Integer = start To message.Length - 1
    text(position) = message(i)
    position = position + 1
Next
4

0 に答える 0