string s = "123.00"; >>>>>string cut = s.IndexOf(".") > 0 ? s.Substring(0, s.IndexOf(".")) : s; >>>>>I'll do unit testing later :-}
class Program { static void Main() { string s = "123.00"; string q = s.RemoveDecimals(); Console.WriteLine("{0} >> {1}", s, q); Console.ReadLine(); } //______________________________________________________________________ } public static class ExtensionMethods { public static string RemoveDecimals(this string s) { retVal= s; decimal val = 0; if(s.Contains('.')) { if(decimal.TryParse(s, out val)) { retVal = Convert.ToString(Convert.ToInt32(val)); } } return retVal; } }