"123.00".Substring(0,s.IndexOf("."))?
string s = "123.00"; >string cut = s.IndexOf(".") > 0 ? s.Substring(0, s.IndexOf(".")) : s; >I'll do unit testing later :-}
// transform -1 to s.Length string result = s.Substring(0, s.IndexOf('.').Mod(s.Length + 1));
//______________________________________________________________________ /// <summary> /// Performs a Remainder calculation where the result has the sign of dividend /// </summary> /// <param name="dividend"></param> /// <param name="divisor"></param> /// <returns></returns> public static Int32 Rem(this Int32 dividend, Int32 divisor) { return (dividend % divisor); } //______________________________________________________________________ /// <summary> /// Performs a Remainder calculation where the result has the sign of dividend /// </summary> /// <param name="dividend"></param> /// <param name="divisor"></param> /// <returns></returns> public static Int64 Rem(this Int64 dividend, Int64 divisor) { return (dividend % divisor); } //______________________________________________________________________
//______________________________________________________________________ /// <summary> /// Performs a Modulo calculation where the result has the sign of divisor /// </summary> /// <param name="dividend"></param> /// <param name="divisor"></param> /// <returns></returns> public static Int32 Mod(this Int32 dividend, Int32 divisor) { return dividend.Rem(divisor) + (Math.Sign(dividend) * Math.Sign(divisor) >= 0 ? 0 : divisor); } //______________________________________________________________________ /// <summary> /// Performs a Modulo calculation where the result has the sign of divisor /// </summary> /// <param name="dividend"></param> /// <param name="divisor"></param> /// <returns></returns> public static Int64 Mod(this Int64 dividend, Int64 divisor) { return dividend.Rem(divisor) + (Math.Sign(dividend) * Math.Sign(divisor) >= 0 ? 0 : divisor); } //______________________________________________________________________ }