vendredi 1 mai 2020

If (read only numerals) C#

I want to create a condition where if (message == numerals) {} I tried bool IsDijitsOnly(), but i have an error as in picture

if (admin == 2 && msg.Message.Text == *int* && step == 3) // here i want add (&& msg.Message.Text == Numerals) where *int*
{
timetable.accept_to_edit(UserId, msg.Message.Text);
}

// Method accept_to_edit, where i tried set instructions for non-numerls and only-numerals message

 public async void accept_to_edit(int UserId, string message)
        {
            bool IsDigitsOnly()
            {
                foreach (char c in message)
                {
                    if (c < '0' || c > '9')
                        return false;
                }

                return true;

            }
            if (true)
            {
                try...                   
            }
            else // Here I have error: unreachable code

Aucun commentaire:

Enregistrer un commentaire