コード例 #1
0
 public static sbyte ObjectToSByte(object obj, sbyte defaultVal = default)
 {
     return(obj switch
     {
         null => defaultVal,
         sbyte myself => myself,
         string str => StringToSByte(str, defaultVal),
         _ => XConvHelper.D(obj.ToString(), StringSByteDeterminer.IS, defaultVal, StringToSByte, out var val)
             ? val
             : XConvHelper.T(() => Convert.ToSByte(ObjectToDecimal(obj, defaultVal)), defaultVal)
     });
コード例 #2
0
 public static DateTime ObjectToDateTime(object obj, DateTime defaultVal = default)
 {
     return(obj switch
     {
         null => defaultVal,
         string str => StringToDateTime(str, defaultVal),
         DateTime d => d,
         _ => XConvHelper.D(obj.ToString(), StringDateTimeDeterminer.IS, defaultVal, StringToDateTime, out var val)
             ? val
             : XConvHelper.T(() => Convert.ToDateTime(obj), defaultVal)
     });