To validate Visa and Mastercard credit cards in C#, we can make use of regular expressions. Here is the code:
main.cs636 chars21 lines
To use this method, simply pass in the credit card number as a string parameter and it will return a boolean indicating whether the number is a valid Visa or Mastercard credit card number.
gistlibby LogSnag