469,270 Members | 1,118 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Current Time in C#

Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks

--
-iwdu15
Nov 24 '06 #1
4 92611
On Thu, 23 Nov 2006 18:25:01 -0800, iwdu15 wrote:
Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks
DateTime current = DateTime.Now;
--
Tom Porterfield
Nov 24 '06 #2
haha wow im oblivious, thanks a lot
--
-iwdu15
Nov 24 '06 #3
Hi
DateTime is a class in System namespace. As Base class library is
shared across the platform, C# can happily use DateTime

You can use the same class DateTime in C# also.

DateTime current = DateTime.Now; will give you the current date time
:-)

Thanks
-Srinivas.


Tom Porterfield wrote:
On Thu, 23 Nov 2006 18:25:01 -0800, iwdu15 wrote:
Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks

DateTime current = DateTime.Now;
--
Tom Porterfield
Nov 24 '06 #4
iwdu15,

"Now" is a method in the standard Net namespace Microsoft.VisualBasic, you
can use it in C# in the same way as every other standard Net namespace.

In VB you can use in two ways the "using" declaration of namespaces. One is
in the project properties and one is in the same way although you use
"Import" in the same way as in C#. In VB.Net are in the same way as in C#
automaticly set some namespaces to use when you open things like a form.
Including in that is forever the namespace VisualBasic, however you don't
see it, it is in the Project Propertys.

For the rest C# and VB.Net are here again exactly the same.

(I would never use this namespace in C# only to get the Now method by the
way).

I hope this explains it a little bit.

Cor

"iwdu15" <jmmgoalsteratyahoodotcomschreef in bericht
news:47**********************************@microsof t.com...
Hi, in VB i could use the keyword Now to get the current DateTime, but C#
doesnt have that. How can i get the current time? thanks

--
-iwdu15

Nov 24 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Chris | last post: by
18 posts views Thread by Tim Quon | last post: by
4 posts views Thread by Gary Wessle | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.