So I have a bool Variabel called isNumber.
bool isNumber(string Text)
{
bool Answer = true;
string Number = "1234567890";
bool ANumber = false;
for(int j = 0; j <Text.Length; j++)//loop for each char in string Text
{
for (int i = 0; i < Number.Length; i++)//loop for each char in the "Number" variable
{
if (Text[j] == Number[i]) //←System.IndexOutOfRangeException: 'Index was outside the bounds of the array.
{
ANumber = true;
}
}
if (!ANumber)
{
Answer = false;
}
}
return Answer;
}
its function is to check a string, if the string is all a number it will return true and return false if there was a non-number char in the string.
but in the loop, there's an error that says indexOutOfRange, but I'm pretty sure it's not. so how do I fix this variable?
or maybe if you have a better working variable to check if a string is a number, lemme know :) thanks for the help. also if you have a suggestion for the title of this forum, just tell me so I will edit the name.