Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Specific Exception Catching | Fundamentals of Exception Handling
C# Exceptions and Error Handling Practice

bookChallenge: Specific Exception Catching

Compito

Swipe to start coding

Implement a method that parses a string to an integer, handling both null and format errors with specific catch blocks.

  • If the input string is null, catch the resulting ArgumentNullException and throw a new ArgumentNullException with the message "Input string is null.".
  • If the input string is not a valid integer format, catch the resulting FormatException and throw a new FormatException with the message "Input string is not in a correct format to parse to int.".
  • If the input string is a valid integer, return its parsed value.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. 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

close

bookChallenge: Specific Exception Catching

Scorri per mostrare il menu

Compito

Swipe to start coding

Implement a method that parses a string to an integer, handling both null and format errors with specific catch blocks.

  • If the input string is null, catch the resulting ArgumentNullException and throw a new ArgumentNullException with the message "Input string is null.".
  • If the input string is not a valid integer format, catch the resulting FormatException and throw a new FormatException with the message "Input string is not in a correct format to parse to int.".
  • If the input string is a valid integer, return its parsed value.

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 1. Capitolo 4
single

single

some-alt