How to copy datetime content from System.ValueType to DateTimevariable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Veeranna Ronad

    How to copy datetime content from System.ValueType to DateTimevariable

    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.
  • =?Utf-8?B?TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd?=

    #2
    RE: How to copy datetime content from System.ValueTyp e to DateTime var


    "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)GetDa te();

    --
    Happy Coding!
    Morten Wennevik [C# MVP]

    Comment

    • Jeff Johnson

      #3
      Re: How to copy datetime content from System.ValueTyp e to DateTime variable

      "Veeranna Ronad" <vyronad@gmail. comwrote in message
      news:1ff8a415-81ee-4b58-82ad-985065f211d5@b3 8g2000prf.googl egroups.com...
      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?


      Comment

      Working...