Click here to Skip to main content
13,593,447 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

12.2K views
2 bookmarked
Posted 27 Apr 2010
Licenced CPOL

Convert ISBN10 To ISBN 13

, 27 Apr 2010
Rate this:
Please Sign up or sign in to vote.
Below function get ISBN10 parameter and return ISBN13 :public string GetISBN13(string ISBN) { string isbn10 = "978" + ISBN.Substring(0, 9); int isbn10_1 = Convert.ToInt32(isbn10.Substring(0, 1)); int isbn10_2 =...
Below function get ISBN10 parameter and return ISBN13 :

public string GetISBN13(string ISBN)
        {
            string isbn10 = "978" + ISBN.Substring(0, 9);
            int isbn10_1 = Convert.ToInt32(isbn10.Substring(0, 1));
            int isbn10_2 = Convert.ToInt32(Convert.ToInt32(isbn10.Substring(1, 1)) * 3);
            int isbn10_3 = Convert.ToInt32(isbn10.Substring(2, 1));
            int isbn10_4 = Convert.ToInt32(Convert.ToInt32(isbn10.Substring(3, 1)) * 3);
            int isbn10_5 = Convert.ToInt32(isbn10.Substring(4, 1));
            int isbn10_6 = Convert.ToInt32(Convert.ToInt32(isbn10.Substring(5, 1)) * 3);
            int isbn10_7 = Convert.ToInt32(isbn10.Substring(6, 1));
            int isbn10_8 = Convert.ToInt32(Convert.ToInt32(isbn10.Substring(7, 1)) * 3);
            int isbn10_9 = Convert.ToInt32(isbn10.Substring(8, 1));
            int isbn10_10 = Convert.ToInt32(Convert.ToInt32(isbn10.Substring(9, 1)) * 3);
            int isbn10_11 = Convert.ToInt32(isbn10.Substring(10, 1));
            int isbn10_12 = Convert.ToInt32(Convert.ToInt32(isbn10.Substring(11, 1)) * 3);
            int k = (isbn10_1 + isbn10_2 + isbn10_3 + isbn10_4 + isbn10_5 + isbn10_6 + isbn10_7 + isbn10_8 + isbn10_9 + isbn10_10 + isbn10_11 + isbn10_12);
            int checkdigit = 10 - ((isbn10_1 + isbn10_2 + isbn10_3 + isbn10_4 + isbn10_5 + isbn10_6 + isbn10_7 + isbn10_8 + isbn10_9 + isbn10_10 + isbn10_11 + isbn10_12) % 10);
            if (checkdigit == 10)
                checkdigit = 0;
            return isbn10 + checkdigit.ToString();
        }

Enjoy it

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mehrdad,Asghari
Web Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180618.1 | Last Updated 27 Apr 2010
Article Copyright 2010 by Mehrdad,Asghari
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid