datetime difference c# code example

Example 1: fdifference between two date in hours c#

double dif = (greaterDate - smallerDate).TotalHours;

Example 2: datetitime contrusctor c#

public struct DateTime : IComparable, IComparable<DateTime>, IConvertible, IEquatable<DateTime>, IFormattable, System.Runtime.Serialization.ISerializable

Example 3: c# hardcode datetime quoting

var yearInt = 2012;
var monthInt = 01;
var dayInt = 01;
var hourInt = 17; //24hr clock
var minuteInt = 45;
var secondInt = 59;

DateTime hardcodeValue = new DateTime(yearInt, monthInt, dayInt, hourInt, minuteInt, secondInt);