Main Site Documentation

General programming question


#1

I have an Byte array with the ascci time and I want to compare it to the current system time
and determine if its < , == , > current time. (for Cobra project) I’m sorta new to C# ???


#2

I think teh easiest way is by converting your string to DateTime object then you can compare the ticks.


#3

Check out http://msdn.microsoft.com/en-us/library/ee432428.aspx for the overloads you can use to create a DateTime object. You’ll obviously have to convert the byte array to integers containing the date parts.

Something like


            //example date byte array
            byte[] dateBytes = new byte[]{11,7,19};

            int year  = (int)dateBytes[0] + 2000;
            int month = (int)dateBytes[1];
            int day   = (int)dateBytes[2];
            DateTime date = new DateTime (year, month, day);

You can use operators (<, >, =, etc) to directly compare dates.


#4

Most excellent - TNX : Ray