示例#1
0
 public static bool TryParse(string s, out Rut rut)
 {
     try
     {
         rut = Rut.Parse(s);
         return true;
     }
     catch (Exception ex)
     {
         rut = null;
         return false;
     }
 }
示例#2
0
        public static Rut Parse(string s)
        {
            if (String.IsNullOrEmpty(s)) throw new ArgumentNullException("s");

            Rut result = new Rut();
            s = s.Trim().Replace("-", "");
            s = s.Trim().Replace(".", "");
            string rutTitularString = s.Substring(0, s.Length - 1);
            result.Numero = int.Parse(rutTitularString);
            result.DV = char.Parse(s.Substring(s.Length - 1).ToUpper());

            return result;
        }