Solved

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

Posted on 2013-01-25
5
358 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
Comment Utility
just like you would any other datetime
0
 
LVL 22

Expert Comment

by:p_davis
Comment Utility
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
Comment Utility
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
Comment Utility
DateTime t1 = new DateTime();

DateTime? t2 = t1;
//or

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

Expert Comment

by:AndyAinscow
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

8 Experts available now in Live!

Get 1:1 Help Now