Dim intChunkId As Integer = &H4D546864
Dim strCunnkId As String = "MThd"
Dim easiestWay = GetString(intChunkId)
views:
25answers:
1
A:
Dim bytes As Byte() = BitConverter.GetBytes(intChunkId)
Dim strChunkId As String = Encoding.ASCII.GetString(bytes)
A couple of points:
- This assumes the bytes in the integer are all the ASCII range (the ones in your example are, but they might not always be: in that case, you can use
Encoding.Default
.) - My VB is a bit rusty, I'm not sure I got the declaration of arrays right...
Dean Harding
2010-07-06 04:23:08
Shimmy
2010-07-06 04:28:01
@Shimmy: yeah, but it's only one extra line :-)
Dean Harding
2010-07-06 04:48:22
It's one extra processing.I guess I will make a second static readonly variable that contains the calculated result.
Shimmy
2010-07-06 12:38:38