C Programming Homework Help – The Best of the Best in the UKThe C programming language is one of the most common languages and the most preferred by the majority of institutions when it comes to introducing learners to programming. Most of the high-level programming languages we have today are a lot...
Validating Phone Numbers in C# in Various Formats
Test Cases
Testing the program with non-numeric characters:
Testing the program with alpha characters:
Testing the program with negative numbers:
Observations
I observed that the C# code that I wrote can validate US phone numbers in different formats. There are no inputs that cause a runtime error because all the data are treated as a string (numbers are treated as string) and no data type conversion necessary that can cause a runtime error. There is no logic error as well but the program is only limited to validating the following phone number formats:- 1-515-867-5309
- The program makes sure that if dialing internationally then the first digit should be 1.
- 515-867-5309
- (515)867-5309