Application value null

  • Thread starter Thread starter Sala
  • Start date Start date
S

Sala

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
 
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
 
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
 
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.
 
Bob Jones said:
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.
 
Quit picking nits. You know what I mean. Show me "MinValue" on a clock.
 
Bob Jones said:
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.
 
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."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top