I want to code this part of a VB6 application in c#.
How can I change a long into a Hex value?
Public Function longToHex(l As Long) As String
longToHex = Hex(l)
If Len(longToHex) < 4 Then longToHex = String(4 - Len(longToHex), "0") & longToHex
longToHex = Right(longToHex, 2) & Left(longToHex, 2)
End Function
Just format to a padded hex string:
Then transpose the first two characters with the last two.
The VB6 code appears to take the length of
sDatadivided by 2, then converts the length to a Hex string and pads it with 0s to 4 characters if needed. It then transposes the first two characters with the last two.