Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Namespace Network
  2. Public Class BooleanByteWrapper
  3. Public Shared Sub SetFlag(ByRef target As Byte, ByVal rank As Integer, ByVal value As Boolean)
  4. Dim array As New BitArray(New Byte() {target})
  5. array.Item(rank) = value
  6. Dim num As Byte = 0
  7. Dim i As Byte = 0
  8. Do While (i < array.Count)
  9. num = CByte((num Or If(array.Item(i), CByte((CInt(1) << i)), CByte(0))))
  10. i = CByte((i + 1))
  11. Loop
  12. target = num
  13. End Sub
  14.  
  15. Public Shared Function GetFlag(ByVal target As Byte, ByVal rank As Integer) As Boolean
  16. Dim array As New BitArray(New Byte() {target})
  17. Return array.Get(rank)
  18. End Function
  19. End Class
  20. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement