-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc_sharp.html
More file actions
44 lines (37 loc) · 798 Bytes
/
Copy pathc_sharp.html
File metadata and controls
44 lines (37 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<h1>Validar RUT!<br>C Sharp C#</h1>
<p>Enviado por Alejandra Cruzat</p>
<pre>
private string digitoVerificador(int rut)
{
int Digito;
int Contador;
int Multiplo;
int Acumulador;
string RutDigito;
Contador = 2;
Acumulador = 0;
while (rut != 0)
{
Multiplo = (rut % 10) * Contador;
Acumulador = Acumulador + Multiplo;
rut = rut/10;
Contador = Contador + 1;
if (Contador == 8)
{
Contador = 2;
}
}
Digito = 11 - (Acumulador % 11);
RutDigito = Digito.ToString().Trim();
if (Digito == 10 )
{
RutDigito = "K";
}
if (Digito == 11)
{
RutDigito = "0";
}
return (RutDigito);
}
}
</pre>