Function to verify that a string has only letters c # console

0

Well, guys I'm doing a program in console, with functions, the program is about an invoice which you must enter the name of a person (name of the product, amount, price ect ..) and calculate the subtotal and total. But since we are working with functions, I must perform a function which allows verifying when the user enters their name, this only contains letters and not numbers or special features, otherwise, give an error message, and let enter it until this is correct Thank you very much in advance for any help I will be very helpful, I am somewhat lost (yes, I am a beginner).

    
asked by Axwell Duarte 07.10.2017 в 18:53
source

1 answer

0

For letters only, use this function:

Regex.IsMatch(variable, @"^[a-zA-Z]+$");

Greetings!

    
answered by 08.10.2017 в 00:09