# [.net] sbyte to System.Timezone?

## Recommended Posts

Ok, here's the thing - I have a class, that I did not make, that has a constructor that takes a TimeZone instance as a parameter;
        public ServerInfo(string name, int fullPercent, TimeZone tz, IPEndPoint address)
{
m_Name = name;
m_FullPercent = fullPercent;
m_TimeZone = tz.GetUtcOffset(DateTime.Now).Hours;
}

Now, that's all well and dandy, but the problem is that the project that this class is in happens to be a server. As such, it creates a packet containing a lot of ServerInfo instances. However, as I'm creating a client for this server, I need to know how to retrieve the data of this packet. The problem is that the server, when it creates the packet in question, converts the ServerInfo's m_TimeZone member to an sbyte like so:
m_Stream.Write((sbyte)si.TimeZone);

Now, obviously this poses a problem for me when I'm trying to create a new ServerInfo class instance in the client based on the information in the packet, since I have to somehow convert an sbyte into a System.TimeZone instance. So far this has proven impossible because System.TimeZone doesn't have any constructors and is impossible to explicitly convert to an sbyte (I.E doing so generates an error). Any suggestions? Thanks in advance!

##### Share on other sites
There's some interesting TimeZone stuff here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=177169&SiteID=1

The TimeZone class is abstract, so the server must be converting a derived class to an sbyte. So, if you could figure out what class that's actually being used, you might have a better chance of converting the sbyte back into a TimeZone-derived object.

##### Share on other sites
Thanks! I sorted it. :)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628395
• Total Posts
2982437

• 10
• 9
• 19
• 24
• 10