Hi, i need help building a method to see if a textbox contains digits or letters. The assignment is to put in the year you are born and then give back how old you are. The tricky part for me is to build a method that will catch if you put letters in your textbox and not break down. Im not allowed to use any built in methods like tryParse och try and catch. ```cs
private void Button_Click(object sender, RoutedEventArgs e)
{
string yearBorn = TxtYearBorn.Text;
bool istrueornot = TryifStringisNumber(yearBorn);
if (istrueornot == false)
{
MessageBox.Show("Du får bara skriva in siffror");
}
else if (istrueornot == true)
{
int integerYearBorn = int.Parse(yearBorn);
int yearBornResult = Age(integerYearBorn);
MessageBox.Show($"You are {yearBornResult} years old");
}
}
public bool TryifStringisNumber(string yearborn)
{
for (int i = 0; i < yearborn.Length; i++)
{
if (i <= 0 )
{
return false;
}
else {
return true; }
}
return false;
}
private int Age(int yearOfBirth)
{
if (yearOfBirth >= 0)
{
return -1;
}
else
{
int currentyear = DateTime.Now.Year;
return currentyear - yearOfBirth;
}
}
}
}