Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Current Time in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
iwdu15 - 24 Nov 2006 02:25 GMT
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

Signature

-iwdu15

Tom Porterfield - 24 Nov 2006 02:53 GMT
> 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;
Signature

Tom Porterfield

iwdu15 - 24 Nov 2006 03:33 GMT
haha wow im oblivious, thanks a lot
Signature

-iwdu15

Duggi - 24 Nov 2006 06:02 GMT
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.

> > 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;
Cor Ligthert [MVP] - 24 Nov 2006 06:17 GMT
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

> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.