else geht nicht

RobinJ 276 Reputation points
2020-11-20T09:20:45.193+00:00

Liebe Community

Ich habe zwei mal ein if/else in meinem Code. Das erste if/else geht ohne Probleme, das zweite jedoch funktioniert nicht.
unten ist das if else welches nicht geht.

if (server_tokens_string == token_eingabe); fortschritt_label.Content = "Checking API-Token..."; progress_bar.Value = 7;
                {
                    title_label.Content = "Gültiger API-Token. Viel Spass mit Liquid Aqua"; fortschritt_label.Content = "API-Check successful finished."; progress_bar.Value = 8;
                }
                else
                {
                    title_label.Content = "API-Token ungültig. Bitte in 5 Sekunden erneut versuchen."; progress_bar.Value = 0; fortschritt_label.Content = null;
                    Thread.Sleep(5000);
                    title_label.Content = "Bitte API-Token erneut eingeben."; progress_bar.Value = 0;
                }
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,011 questions
{count} votes

Accepted answer
  1. RobinJ 276 Reputation points
    2020-11-23T20:21:32.507+00:00

    Hi Peter,
    should this work so?

    //Überprüfung Token
                    if (server_token_string == token_eingabe)
                    {
                        title_label.Content = "Gültiger API-Token. Viel Spass mit Liquid Aqua"; fortschritt_label.Content = "API-Check successful finished."; progress_bar.Value = 8;
                        Environment.Exit(0);
                    }
                    else
                    {
                        //Ungültiger Token
                        title_label.Content = @$"Ungültiger Token {token_eingabe}. Bitte erneut versuchen."; progress_bar.Value = 0; fortschritt_label.Content = $"Ungültiger Token {token_eingabe}. Bitte erneut versuchen.";
                    }
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.