title: How do I validate a UPC or EAN code?
body: <p>I need a C# .NET function to evaluate whether a typed or scanned barcode is a valid <a href="http://en.wikipedia.org/wiki/Global_Trade_Item_Number" rel="noreferrer">Global Trade Item Number</a> (UPC or EAN).</p>
  
  <p><img src="https://i.stack.imgur.com/CR80w.gif" alt="barcode check digit"></p>
  
  <p>The last digit of a bar code number is a computer Check Digit which makes sure the bar code is correctly composed. <a href="http://www.gs1.org/barcodes/support/check_digit_calculator" rel="noreferrer">GTIN Check Digit Calculator</a></p>