• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

Assign a System.DateTime variable to a System.DateTime[?]

How do I assign a System.DateTime variable to a System.DateTime? variable?
0
allelopath
Asked:
allelopath
  • 3
1 Solution
 
p_davisCommented:
just like you would any other datetime
0
 
p_davisCommented:
the other way though you would have to either cast to datetime or use the datetime?'s value property
0
 
allelopathAuthor Commented:
I get this compile error:
Cannot convert source type System.Nullable<System.DateTime> to target type <System.DateTime>
0
 
p_davisCommented:
DateTime t1 = new DateTime();

DateTime? t2 = t1;
//or

t1 = t2.Value
//or
t1 = (DateTime)t2
0
 
AndyAinscowCommented:
System.DateTime? means that it is either a System.DateTime OR a null.  
System.DateTime means it can ONLY be a System.DateTime.

In other words they are they same apart from one being able to have a value null.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now