Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Debugging a Broken Program | Safe File Operations and Debugging
C# Exceptions and Error Handling Practice

bookChallenge: Debugging a Broken Program

Aufgabe

Swipe to start coding

You are given a program that attempts to read the contents of a file and print them to the console. However, if the file does not exist, the program throws an exception and crashes. Your task is to fix the program so that it handles the missing file gracefully and no longer crashes when the file is absent.

  • Return "File does not exist." if the file at the given path is missing.
  • Otherwise, return the contents of the file.

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 4
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

close

bookChallenge: Debugging a Broken Program

Swipe um das Menü anzuzeigen

Aufgabe

Swipe to start coding

You are given a program that attempts to read the contents of a file and print them to the console. However, if the file does not exist, the program throws an exception and crashes. Your task is to fix the program so that it handles the missing file gracefully and no longer crashes when the file is absent.

  • Return "File does not exist." if the file at the given path is missing.
  • Otherwise, return the contents of the file.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 4
single

single

some-alt