Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
C# code, C# Programming, C# Tutorial
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.
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);
For learn more about C# plz visit on this link.http://www.csharptalk.com/
0 · ·