I\'ve inherited C# code that has an awful lot of DateTimes where the Kind property is DateTimeKind.Unspecified. These are fed into Datetime.ToUniversalTime() which gives ba
I use an extension method:
public static DateTime SetKind(this DateTime DT, DateTimeKind DTKind)
{
var NewDT = New DateTime(DT.Year, DT.Month, DT.Day, DT.Hour, DT.Minute, DT.Second, DT.Millisecond, DTKind);
Return NewDT;
}
This is much shorter to use in LINQ than having to type out DateTime.SpecifyKind(unspecified, DateTimeKind.Utc) every time.
For example:
table.Where((x) x.StartTimeStampUTC.SetKind(DateTimeKind.Utc).ToString("G") = GUIStartTimeStampTxt.Text)