473,387 Members | 1,318 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.
Oct 30 '08 #1
2 2306

"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]
Oct 30 '08 #2
"Veeranna Ronad" <vy*****@gmail.comwrote in message
news:1f**********************************@b38g2000 prf.googlegroups.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?
Oct 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jean Stax | last post by:
Hi ! Jeffrey Richter gives the following example in his book: struct Point { Int32 x, y; } class AAA{ .... public virtual void Add(Object value);
5
by: Vitling | last post by:
For no apparent reason, a NullReference exception is thrown in system.dll (System.Net.Sockets.OverlappedAsyncResult.CompletionPortCallback). Since I only get a disassembly from Visual Studio, it...
6
by: Sahil Malik | last post by:
Okay, I can't inherit from System.ValueType. Why this restriction?? What I am trying to acheive is, create my own ValueType called "Money". So if I have a decimal that has value 1.93991, when...
44
by: Frank Rizzo | last post by:
Any ideas?
3
by: Claire | last post by:
Ive been writing DateTime variables to streams the long way binarywriter.write((int)Day); binarywriter.write((int)Hour) etc Is there a conversion routine or some other way to shorten the process of...
5
by: Kevin Yu | last post by:
hi all since the DateTime can't be assign null, the min value is set to 1901 or something, if in a application design, the date field can be null, so in between the UI and the DB, the business...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
6
by: jr1024 | last post by:
Hi everybody! I have a C# app that connects to a mdb file and displays all the fields from a table in dataGridView. I have trouble searching in a Access Date/Time field like this. string...
3
by: soren.enemaerke | last post by:
Hi everybody. I'm writing a .NET wrapper class for a native C++ library and decided to do it in C++/CLI. One of the problems I ran in to is the following. In C++ I have the following public...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.