<System.Runtime.CompilerServices.Extension()> _ Public Function ToStringリテラル(dt As DateTime, Optional IsDayOnly As Boolean = False) As String Dim fmt As System.IFormattable = $"#{dt:MM/dd/yyyy HH:mm:ss.fffffff}#" If IsDayOnly Then fmt = $"#{dt:MM/dd/yyyy}#" Return fmt.ToString(Nothing, System.Globalization.CultureInfo.InvariantCulture) End Function
Return If(IsDayOnly, $"#{dt:MM\/dd\/yyyy}#", $"#{dt:MM\/dd\/yyyy HH\:mm\:ss\.fffffff}#")