Ver por etiquetas

Tip/Trick: Validar un DNI
Published 29/8/2007 17:42 | Eugenio Estrada
Esta es una función bastante útil, sirve para validar la letra de un DNI. Pasandole como parámetro el DNI completo, letra incluída. bool validarDNI( string dni) { if ( new Regex(" [0-9]{8}[A-Za-z] ").Match(dni).Success) { return (" TRWAGMYFPDXBNJZSQVHLCKE "[( int ) long .Parse(dni.Substring(0, 8)) % 23].ToString() == dni .ToString().ToUpper()); } else { return false ; } } Espero que os sea útil
Archivado en: ,,

Search

This Blog

Tags

Community

Archives

Blogs

Enlaces recomendados

Syndication

Email Notifications

Enlaces Comunes