BinaryStream: Enums

Hello everyone!

How can i store Enumerations within a BinaryStream (and how to load it)? This will not working for me on OS X.

[code]Enum Calendar As Integer
Gregorian
Julian
Hebrew
End Enum

Sub Load(s As BinaryStream)
#If Target64Bit
Calendar = Calendar(Int64(s.ReadInt64))
#Else
Calendar = Calendar(Int32(s.ReadInt32))
#EndIf
End Sub

Sub Save(s As BinaryStream)
#If Target64Bit
s.WriteInt64(Int64(Calendar))
#Else
s.WriteInt32(Int32(Calendar))
#EndIf
End Sub[/code]

Greetings!

You need to create and use Calendar variable.

Writing:

Dim calendarValue As Calendar = Calendar(s.ReadInt32())

Reading:

Dim calendarValue As Calendar = Calendar.Julian s.WriteInt32(Int32(calendarValue))