Geeks With Blogs
Fórmulas e Cenas Object Reference Not Set to an Instance of an Object

Well... I cant really express my feelings for this kind of programming...

The WTF way:

DateTime myNewDate = DateTime.Parse((myOldDate.Year - 1).ToString() + "-" + myOldDate.Month.ToString() + "-" + myOldDate.Day.ToString());

 

The right way:

 DateTime myNewDate = myOldDate.Date.AddYears(-1);

 

Posted on Tuesday, March 23, 2010 12:17 PM Geral , C# , Fun | Back to top


Comments on this post: WTF #4

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Sglima | Powered by: GeeksWithBlogs.net