//Namespace Referenceusing System.Text.RegulsrExpressions/// /// method to validate a credit card number/// /// cc number to validate/// true/falsepublic static bool validCCNum(string num){ // This expression is looking for a series of numbers, which follow the pattern // for Visa, MC, Discover and American Express. It also allows for dashes between sets of numbers string pattern = @"^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7][\d\s-]{15}$"; Regex match = new Regex(pattern); return match.IsMatch(num);}