I was wondering if I can shorten this:
bool Check()
{
return textBox1.Text.All(char.IsDigit) ? true : Falsepath();
}
bool Falsepath()
{
MessageBox.Show("The data you entered is incorrect","Error",MessageBoxButtons.OK);
return false;
}
To something like this:
bool Check()
{
return textBox1.Text.All(char.IsDigit) ? true : (sender, e) =>
{
MessageBox.Show("The data you entered is incorrect", "Error", MessageBoxButtons.OK);
return false;
};
}
Of course, this second code I entered is not correct, but I'm using it as an example.
So, can I execute a code while checking something or do I have to use separate funtions?