Imports System
Imports System.Collections.Generic
Public Class Program
Public Shared Function RemoveTrailingNulls(ByVal byteList As List(Of Byte)) As List(Of Byte)
While byteList.Count > 0 AndAlso byteList(byteList.Count - 1) = 0
byteList.RemoveAt(byteList.Count - 1)
End While
Return byteList
End Function
Public Shared Sub Main()
Dim byteList As List(Of Byte) = New List(Of Byte) From {
1,
2,
3,
0,
0,
0,
0
}
Dim trimmedList As List(Of Byte) = RemoveTrailingNulls(byteList)
For Each b As Byte In trimmedList
Console.Write(b & " ")
Next
End Sub
End Class
' run:
'
' 1 2 3
'