What is the smallest amount of C# possible to Check that a String fits this format #-#####
(1 number, a dash then 5 more numbers).
It seems to me that a regular expression could do this quick (again, I wish I knew regular expressions).
So, here is an example:
public bool VerifyBoxNumber (string boxNumber)
{
// psudo code
if (boxNumber.FormatMatch("#-#####")
return true;
return false;
}
If you know real code that will make the above comparison work, please add an answer.
private static readonly Regex boxNumberRegex = new Regex(@"^\d-\d{5}$");
public static bool VerifyBoxNumber (string boxNumber)
{
return boxNumberRegex.IsMatch(boxNumber);
}
return Regex.IsMatch(boxNumber, @"^\d-\d{5}$");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With