Sign in to follow this  
Afr0m@n

[.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;
            m_Address = address;
        }
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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this