?
Solved

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

Posted on 2013-01-25
5
Medium Priority
?
364 Views
Last Modified: 2013-01-25
How do I assign a System.DateTime variable to a System.DateTime? variable?
0
Comment
Question by:allelopath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 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