C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2598
Number of posts: 5566

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
C# code, C# Programming, C# Tutorial Posted by harshkumar on 13 Oct 2009 at 10:46 AM
C# Date/Time

The DateTime.Substract adjustment may be acclimated in adjustment to acquisition the date/time aberration amid two instances of the DateTime method. This method does not change the value of the DateTime instance on which the method has been invoked. The aftereffect of the operation is stored in the new TimeSpan structure.

The TimeSpan chic has a bifold set of properties, one set represents the time durations in integers and addition set of properties, with the names prefixed with "Total" represents the result in fractional values. The afterward sample cipher illustrates the use of the DateTime.Subtract adjustment and the Days and TotalDays backdrop of the TimeSpan structure.

The DateTime structure also has an overload for the Subtract method which accepts a TimeSpan and returns the DateTime value which is the result of subtracting the Timespan argument from the value of the DateTime structure on which the Subtract method has been invoked.

using System;

using System.Collections.Generic;

using System.Text;

namespace Console_DateTime

{

class Program

{

static void Main(string[] args)

{

System.DateTime dtTodayNoon = new System.DateTime(2006, 9, 13, 12, 0, 0);

System.DateTime dtTodayMidnight = new System.DateTime(2006, 9, 13, 0, 0, 0);

System.TimeSpan diffResult = dtTodayNoon.Subtract(dtYestMidnight);

Console.WriteLine("Yesterday Midnight - Today Noon = " + diffResult.Days);

Console.WriteLine("Yesterday Midnight - Today Noon = " + diffResult.TotalDays);

Console.ReadLine();

}

}

}

For learn more about C# plz visit on this link.

http://www.csharptalk.com/



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.