Solved

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

Posted on 2013-01-25
5
359 Views
Last Modified: 2013-01-25
How do I assign a System.DateTime variable to a System.DateTime? variable?
0
Comment
Question by:allelopath
  • 3
5 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 38819330
just like you would any other datetime
0
 
LVL 22

Expert Comment

by:p_davis
ID: 38819332
the other way though you would have to either cast to datetime or use the datetime?'s value property
0
 
LVL 1

Author Comment

by:allelopath
ID: 38819337
I get this compile error:
Cannot convert source type System.Nullable<System.DateTime> to target type <System.DateTime>
0
 
LVL 22

Accepted Solution

by:
p_davis earned 500 total points
ID: 38819341
DateTime t1 = new DateTime();

DateTime? t2 = t1;
//or

t1 = t2.Value
//or
t1 = (DateTime)t2
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 38819348
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now