public static sbyte ConvertStringToSByte(String str, IntegerStringFormatType type) { switch (type) { case IntegerStringFormatType.HexBinary: return Convert.ToSByte(str, 16); case IntegerStringFormatType.Decimal: return Convert.ToSByte(str, 10); case IntegerStringFormatType.Octed: return Convert.ToSByte(str, 8); case IntegerStringFormatType.Binary: return Convert.ToSByte(str, 2); case IntegerStringFormatType.RomanNumeral: return (sbyte)MathUtils.FromRomanNumerals(str); default: throw new NotImplementedException(); } }
public static String ToString(this long value, IntegerStringFormatType type) { switch (type) { case IntegerStringFormatType.HexBinary: return Convert.ToString(value, 16); case IntegerStringFormatType.Decimal: return Convert.ToString(value, 10); case IntegerStringFormatType.Octed: return Convert.ToString(value, 8); case IntegerStringFormatType.Binary: return Convert.ToString(value, 2); case IntegerStringFormatType.RomanNumeral: return MathUtils.ToRomanNumerals(value); default: throw new NotImplementedException(); } }
public static String ToString(this char value, IntegerStringFormatType type) { switch (type) { case IntegerStringFormatType.HexBinary: return(Convert.ToString(value, 16)); case IntegerStringFormatType.Decimal: return(Convert.ToString(value, 10)); case IntegerStringFormatType.Octed: return(Convert.ToString(value, 8)); case IntegerStringFormatType.Binary: return(Convert.ToString(value, 2)); case IntegerStringFormatType.RomanNumeral: return(MathUtils.ToRomanNumerals(value)); default: throw new NotImplementedException(); } }
public static ushort ConvertStringToUShort(String str, IntegerStringFormatType type) { switch (type) { case IntegerStringFormatType.HexBinary: return(Convert.ToUInt16(str, 16)); case IntegerStringFormatType.Decimal: return(Convert.ToUInt16(str, 10)); case IntegerStringFormatType.Octed: return(Convert.ToUInt16(str, 8)); case IntegerStringFormatType.Binary: return(Convert.ToUInt16(str, 2)); case IntegerStringFormatType.RomanNumeral: return((ushort)MathUtils.FromRomanNumerals(str)); default: throw new NotImplementedException(); } }