public static sbyte?GetSByte(object val, bool parse) { if (val == null) { return(null); } try { TypeCode tc = val.GetTypeCode(); switch (tc) { case TypeCode.String: if (!parse) { return(null); } sbyte n; if (!TryFromServer(Convert.ToString(val), out n, 0)) { return(null); } return(n); case TypeCode.Byte: return(unchecked ((sbyte)(byte)val)); default: if (IsNumeric(tc)) { return(Convert.ToSByte(val)); } byte[] b = val as byte[]; int ix = 0; if (b?.Length == sizeof(byte)) { return(IOEx.GetSByte(b, ref ix)); } return(null); } } catch { return(null); } }