I can check if a string contains an integer but unable to do for a alphabet?
Remember to use Regex class, you have to use namespace System.Text.RegularExpressions in your import
or one more way
bool result = hello.Any(function(x) NOT char.IsLetter(x))
For above you have to import System.LINQ namespaces in your project.
Thank you for your help
For alphabets it’s working fine but I want to check for numbers as well
If you want to just check a string is only alphabets and Numbers then you can use below Regex Patter,
Int Count = Regex.Matches(str,"^[a-zA-Z0-9]+$").Count
By Linq -
ool IsAlphnumornot="Your String".All(function(c) Char.IsLetterOrDigit(c))
or if you want to check that any character is Alphanumeric or Digits/Number as well then can use below Linq
Bool IsAlphnumornot="Your String".Any(function(c) Char.IsLetterOrDigit(c))
Thanks @aksh1yadav It’s working
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.