PC Review


Reply
Thread Tools Rate Thread

How to copy datetime content from System.ValueType to DateTimevariable

 
 
Veeranna Ronad
Guest
Posts: n/a
 
      30th Oct 2008
Hello,

Our application gets datetime from an interface function. This
function returns "ValueType". How to copy datetime content from this
"ValueType" to DateTime variable?

Thanks in advance and regards,
Veeranna Ronad.
 
Reply With Quote
 
 
 
 
Morten Wennevik [C# MVP]
Guest
Posts: n/a
 
      30th Oct 2008

"Veeranna Ronad" wrote:

> Hello,
>
> Our application gets datetime from an interface function. This
> function returns "ValueType". How to copy datetime content from this
> "ValueType" to DateTime variable?
>
> Thanks in advance and regards,
> Veeranna Ronad.
>


Hi Veeranna,

A direct cast should work, although I can't imagine why you would return a
the date as "ValueType".

public ValueType GetDate()
{
return DateTime.Now;
}

....

DateTime dt = (DateTime)GetDate();

--
Happy Coding!
Morten Wennevik [C# MVP]
 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      30th Oct 2008
"Veeranna Ronad" <(E-Mail Removed)> wrote in message
news:1ff8a415-81ee-4b58-82ad-(E-Mail Removed)...

> Our application gets datetime from an interface function. This
> function returns "ValueType".


Okay, now I'm curious. Can anyone give me a good example of when you would
actually want to return ValueType from a function?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.ValueType and string builder Tony Johansson Microsoft C# .NET 0 21st Sep 2008 07:25 PM
Generics, System.ValueType and Complex Numbers Ravi Shekhar Microsoft C# .NET 2 19th Jan 2007 06:09 PM
System.ValueType Sahil Malik Microsoft C# .NET 6 1st Jan 2005 08:34 PM
System.ValueType =?Utf-8?B?a2F0?= Microsoft C# .NET 1 19th Oct 2004 11:25 PM
System.ValueType =?Utf-8?B?QnJpYW4gTGluZGVu?= Microsoft Dot NET Framework 2 28th Jul 2004 07:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 AM.