织梦CMS - 轻松建站从此开始!

abg欧博官网|登陆|游戏|

Validar RFC de persona fisica o moral C#

时间:2025-07-18 19:59来源: 作者:admin 点击: 2 次
private bool CheckRFC(string RFCString) { try { if ((string.IsNullOrEmpty(RFCString)) || (string.IsNullOrWhiteSpace(RFCString))) //Verifica que n

private bool CheckRFC(string RFCString) { try { if ((string.IsNullOrEmpty(RFCString)) || (string.IsNullOrWhiteSpace(RFCString))) //Verifica que no venga nulo o en blanco el RFC { throw new ArgumentNullException ("RFCString","RFC esta vacío"); } else { RFCString = String.Concat(RFCString.Where(c => !Char.IsWhiteSpace(c))); // Quita cualquier espacio en blanco de la cadena RFCString = RFCString.ToUpper(); // Pasa a mayusculas el RFC if (RFCString.Length == 13) { // try { string rfcName = (RFCString.Substring(0,4)); string rfcDate = (RFCString.Substring(4,6)); string rfcHomoClave = (RFCString.Substring(10,3)); bool isDigitPresent = rfcName.Any(c=> char.IsDigit(c)); if (isDigitPresent) { throw new Exception("Existe un digito en los primeros 4 caracteres del RFC"); return false; } else // Es correcto el nombre en el RFC { if (rfcDate.All(char.IsDigit)) // Es correcta la fecha de nacimiento { return true; } else // Es incorrecta la fecha de nacimiento { throw new Exception("Existen caracteres en la fecha de nacimiento del RFC"); return false; } } } catch (Exception) { throw; } } else { throw new ArgumentException("RFCString","Error en la longitud del RFC, deben ser 12 caracteres"); return false; } } } catch (Exception ex) { throw; }

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-07-24 22:07 最后登录:2025-07-24 22:07
栏目列表
推荐内容