Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Moin moin,

kann mir einer einen Tip geben. Wie ich es verhindern kann

das bei C#. Bei einer Abfrage das Programm bei Eingabe von

anderen Buchstaben als j oder n weiterläuft. Wobei die

Groß und kleinschreibung keine Rolle Spielen sollte.

Gruß

Kawa

+ ein Frohes Fest noch zu haben

Moin!

Ich moechte auch noch die Compare-Methode ins Spiel bringen, bei der man auch Case insensitiv vergleichen kann, bzw. die ToUpper- und ToLower- Methoden, um nur noch auf Gross- oder Kleinschreibung vergleichen muss.

Zu dieser Thematik hier ein kleines aber vollständiges Progrämmchen:

using System;


namespace YesNoQuestion

{

    class Program

    {

        static void Main(string[] args)

        {

            bool antwort;

            string frage = "Heute schon gefruehstueckt";


            antwort = YesNoQuestion(frage, false);

            Console.WriteLine(String.Format("Deine Antwort auf die Frage:\n\"{0}\"\nlautete: {1}", frage, antwort ? "Ja" : "Nein"));

        }


        static bool YesNoQuestion(string q, bool caseSensitive)

        {

            bool answered = false;

            string input = "";


            if (q != null && q != String.Empty)

            {

                Console.WriteLine(String.Format("{0}{1} (J/N)", q, !q.EndsWith("?") ? "?" : null));

                while (!answered)

                {

                    input = Console.ReadLine();

                    if ((!caseSensitive && (input.ToLower() == "j" || input.ToLower() == "n"))

                        || (caseSensitive && (input == "J" || input == "N"))

                        )

                    {

                        answered = true;

                    }

                    else

                    {

                        //Hier kann auf sämtliche Falscheingaben reagiert werden (zB Ausgabe einer Meldung)

                    }

                }

                if (input.ToLower() == "j")

                {

                    return true;

                }

            }

            return false;

        }

    }

}

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.