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

bookChallenge: Debugging a Broken Program

Compito

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.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 4
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me a real-world example?

close

bookChallenge: Debugging a Broken Program

Scorri per mostrare il menu

Compito

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.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 4
single

single

some-alt