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

bookChallenge: Specific Exception Catching

Tarea

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.

Solución

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 4
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

close

bookChallenge: Specific Exception Catching

Desliza para mostrar el menú

Tarea

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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 4
single

single

some-alt