1 using System;
2 using System.Collections
3
4 public class MyClass
5 {
6 public static Voi D Main ()
7 {
8 Console.WriteLine (per15to18 ("429005811009091"));
9 RL ();
"
"
Publ IC static string Per15to18 (String peridsrc)
{
# int is = 0;
16//Weighted factor constant
Int[] iw=new int[ ]{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
18//Checksum code constant
lastcode= "10x98765432";
20//New ID number
string peridnew;
Peridnew=p Eridsrc.substring (0,6);
24//Fill in 6th and 7th for ' 1 ', ' 9 ' two number
Peridnew + + + + peridnew + + peridsrc.substring (6,9);
28
29//weighted sum
for (int i=0; i<17; i++)
-{
is + = Int. Parse (peridnew.substring (i,1)) * Iw[i];
33}
35
//modulo operation, get modulus
+ int iY = is%11
37//from Lastcode to take the value of modulo index number, add to the last one of the ID card, that is, the new ID number.
Peridnew + = lastcode.substring (iy,1);
Peridnew;r> (
)
\
-Helper Methods#region helper methods
$
-private static void WL (obj ECT text, params object[] args)
$ {
Console.WriteLine (text. ToString (), args);
51}
The private static void RL ()
{
-console.readline ();
"
"
void Break ()
System.Diagnostics.Debugger.Break {
():
"
"
#endregion
"
" /p>
Http://www.cnblogs.com/goody9807/archive/2006/11/13/559378.html