How do I find:
string str="(120)(1500)x";
How to find out in the event that the string contains:
string str1="()()X";
I then have to print:
console.writeline("str1 doesnt contain a numerical");
How do I find:
string str="(120)(1500)x";
How to find out in the event that the string contains:
string str1="()()X";
I then have to print:
console.writeline("str1 doesnt contain a numerical");
var input = "asdfasfas";
if (!Regex.IsMatch(input, "[0-9]"))
{
// will occure
}
else
{
// will not occure
}
var input2 = "asdf123Aasdfasdf";
if (!Regex.IsMatch(input2, "[0-9]"))
{
// will not occure
}
else
{
// will occure
}
but remember: this will only check, if there are any digits, not that the string is easily convertable to a number!
You can do what you need (wich is quite unclear) with regular expressions (Regex class).
If you don't want to use regular expression, you can find the index of '(' and ')' and calculate if the content is empty.