将13位图书条码转换为ISBN-10(2007年以前图书)的方法
/**/
/// <summary>
/// 2007年前图书13条码转换成ISBN-10位方法
/// </summary>
/// <param name="Isbn13">13位条形码</param>
/// <returns>10位isbn编号</returns>
public
static
string
GetISBN10(
string
Isbn13)
![](https://i-blog.csdnimg.cn/blog_migrate/a41954a27d6ad96fa2c2cf816e677448.gif)
...
{
if ( Isbn13.Length == 13 )
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
string Location4 = Isbn13.Substring(3 , 1);
string Location5 = Isbn13.Substring(4 , 1);
string Location6 = Isbn13.Substring(5 , 1);
string Location7 = Isbn13.Substring(6 , 1);
string Location8 = Isbn13.Substring(7 , 1);
string Location9 = Isbn13.Substring(8 , 1);
string Location10 = Isbn13.Substring(9, 1);
string Location11 = Isbn13.Substring(10, 1);
string Location12 = Isbn13.Substring(11 , 1);
string location13 = Isbn13.Substring(11 , 1);
int loc12 = Convert.ToInt16(Location12);
int loc11 = Convert.ToInt16(Location11);
int loc10 = Convert.ToInt16(Location10);
int loc9 = Convert.ToInt16(Location9);
int loc8 = Convert.ToInt16(Location8);
int loc7 = Convert.ToInt16(Location7);
int loc6 = Convert.ToInt16(Location6);
int loc5 = Convert.ToInt16(Location5);
int loc4 = Convert.ToInt16(Location4);
int isbnSum =10 -( loc4 * 10 + loc5 * 9 + loc6 * 8 + loc7 * 7 + loc8 * 6 + loc9 * 5 + loc10 * 4 + loc11 * 3 + loc12 * 2)%11;
if ( isbnSum == 0 )
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
location13 = "0";
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
if ( isbnSum == 1 )
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
location13 = "X";
}
else
![](https://i-blog.csdnimg.cn/blog_migrate/37c8bf68cdc3cc81759c34160776bc53.gif)
...{
isbnSum = 11 - isbnSum;
location13 = isbnSum.ToString();
}
}
return Location4 + Location5 + Location6 + Location7 + Location8 + Location9 + Location10 + Location11 + Location12 + location13;
}
}