Connecting Tech Pros Worldwide Forums | Help | Site Map

Application value null

Sala
Guest
 
Posts: n/a
#1: Nov 25 '06
Hi experts!
If system time 12:00 am my application variable value will be
null.. I am trying to get null value of application but that time i'll
make some actions to that page.. So pls tell me how i'll make null


Chris
Guest
 
Posts: n/a
#2: Nov 25 '06

re: Application value null


I'd like to help, but I'm having difficulty understanding what you are
trying to say. Can you post a snippet of your code that shows the problem
you are having?

Thanks,
-Chris

"Sala" <salavudeen.a@gmail.comwrote in message
news:1164430544.827953.203240@45g2000cws.googlegro ups.com...
Quote:
Hi experts!
If system time 12:00 am my application variable value will be
null.. I am trying to get null value of application but that time i'll
make some actions to that page.. So pls tell me how i'll make null
>
David Boucherie & Co
Guest
 
Posts: n/a
#3: Nov 25 '06

re: Application value null


If system time 12:00 am my application variable value will be
Quote:
null.. I am trying to get null value of application but that time i'll
make some actions to that page.. So pls tell me how i'll make null
I'm not sure I understand your question, but if you're asking how to set
a DateTime to null, the answer is, you can't, it's a value type.

However, you can use a nullable version of DateTime (if you are using
the latest C# version).

Something like this:

//-----------------------------------------
private DateTime? MyTime()
{
DateTime? now = DateTime.Now;
if ( now.Value.TimeOfDay == new TimeSpan( 0, 0, 0 ) )
now = null;
return now;
}
//-----------------------------------------

By the way, DateTime? is just a syntactic shortcut for:
Nullable<DateTime>

I hope I answered the right question. :)

David

Bob Jones
Guest
 
Posts: n/a
#4: Nov 25 '06

re: Application value null


Another possibility is to use DateTime.MaxValue or DateTime.MinValue.
These are guaranteed to be greather than, or less than, respectively
than any actual datetime value. You could use these as a kind of pseudo
null value. AND it's of type DateTime, of course.


On 2006-11-25 05:50:29 -0600, David Boucherie & Co
<david.boucherie@telenet.besaid:
Quote:
Quote:
> If system time 12:00 am my application variable value will be
>null.. I am trying to get null value of application but that time i'll
>make some actions to that page.. So pls tell me how i'll make null
>
I'm not sure I understand your question, but if you're asking how to
set a DateTime to null, the answer is, you can't, it's a value type.
>
However, you can use a nullable version of DateTime (if you are using
the latest C# version).
>
Something like this:
>
//-----------------------------------------
private DateTime? MyTime()
{
DateTime? now = DateTime.Now;
if ( now.Value.TimeOfDay == new TimeSpan( 0, 0, 0 ) )
now = null;
return now;
}
//-----------------------------------------
>
By the way, DateTime? is just a syntactic shortcut for:
Nullable<DateTime>
>
I hope I answered the right question. :)
>
David

Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#5: Nov 25 '06

re: Application value null


Bob Jones <robert@joneshouse.comwrote:
Quote:
Another possibility is to use DateTime.MaxValue or DateTime.MinValue.
These are guaranteed to be greather than, or less than, respectively
than any actual datetime value. You could use these as a kind of pseudo
null value. AND it's of type DateTime, of course.
Well, they're guaranteed to be greater than or less than any *other*
actual DateTime value - but they're valid DateTime values in
themselves.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Bob Jones
Guest
 
Posts: n/a
#6: Nov 26 '06

re: Application value null


Quit picking nits. You know what I mean. Show me "MinValue" on a clock.

On 2006-11-25 12:33:10 -0600, Jon Skeet [C# MVP] <skeet@pobox.comsaid:
Quote:
Bob Jones <robert@joneshouse.comwrote:
Quote:
>Another possibility is to use DateTime.MaxValue or DateTime.MinValue.
>These are guaranteed to be greather than, or less than, respectively
>than any actual datetime value. You could use these as a kind of pseudo
>null value. AND it's of type DateTime, of course.
>
Well, they're guaranteed to be greater than or less than any *other*
actual DateTime value - but they're valid DateTime values in themselves.

Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#7: Nov 26 '06

re: Application value null


Bob Jones <robert@joneshouse.comwrote:
Quote:
Quit picking nits. You know what I mean. Show me "MinValue" on a clock.
I could show you January 1st 1AD on a calendar just as easily as I
could show you January 2nd 1AD.

Just beceause you won't see it called MinValue doesn't mean that
they're not "actual" DateTime values.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Bob Jones
Guest
 
Posts: n/a
#8: Nov 26 '06

re: Application value null


On 2006-11-26 01:59:16 -0600, Jon Skeet [C# MVP] <skeet@pobox.comsaid:
Quote:
Bob Jones <robert@joneshouse.comwrote:
Quote:
>Quit picking nits. You know what I mean. Show me "MinValue" on a clock.
>
I could show you January 1st 1AD on a calendar just as easily as I
could show you January 2nd 1AD.
>
Just beceause you won't see it called MinValue doesn't mean that
they're not "actual" DateTime values.
Ok, ok. We're violently agreeing here. I quote my previous post:
" AND it's of type DateTime, of course."

Closed Thread