Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to define Time type?
Message
 
 
À
01/12/2007 10:33:03
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01272620
Message ID:
01272657
Vues:
15
Thank you for your help. I knew how to initialize a DateTime type. But since I need only the time portion, I thought that maybe I was missing a Time type. Therefore, I will need to initialize my "time" variable with current (now) year, month, and day and set the time arguments from external source (xml file).

>Here's an example of setting a Datetime variable:
>
>DateTime time = new DateTime(2002, 4, 22, 16, 8, 44);
>
>//Time = 4/22/02 16:08:44
>
>Retrieve just time:
>
>Console.WriteLine("Time of Day: {0}\n", time.TimeOfDay);
>
>Datetime's hold both date and time.
>
>
>>I need to do a comparison of Time of day to a Time variable.
>>
>>I would use code like this:
>>
>>
>>if (DateTime.Now.CompareTo( MyTime ) >= 0)
>>
>>
>>My question is, say I want to set value of "12:40" to the variable Mytime. How do I define it?
>>
>>I tried:
>>
>>
>>DateTime.Now.TimeOfDay MyTime = "12:40";
>>
>>
>>But I get compiler error.
>>
>>Thank you in advance for your help.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform