The Darkness Behind DateTime.Now
page 7 of 7
by Keyvan Nayyeri
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 40713/ 62

Summary

Many .NET developers misuse the properties of DateTime structure and apply Now for purposes where it’s not designed for which reduces the performance of the code. UtcNow is what should be used for many cases rather than Now, and even for timing measurements there is a particular class called Stopwatch.

Seeing a quantitative comparison between these approaches visualized in a simple diagram, you can understand why it’s recommended to use each property or type in its own place. I am very sure that the misuse of these options in the .NET codes written in the past decade has had a major impact on many .NET applications and I hope that better training on this topic and similar ones prevents such mistakes from happening.

I’ve uploaded the sample code for this post that you can run on your machine to compare these three approaches yourself.

Download

[Download Sample]

The source code sample for this article is available for download.


View Entire Article

User Comments

Title: 你们不能明白   
Name: 巴拿马
Date: 2012-12-08 3:41:36 AM
Comment:
巴拿马






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-11-29 6:18:03 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search