Getsuyodev, Programming is mainly used when constructing an application. Programming requires knowledge of application domains, algorithms, and programming language expertise. Programming can be developed in different logic based on developer knowledge.

TQ – exception

Thèmes des Questions – C# (C Sharp)



Lorsque le programme de gauche est compilé, le compilateur détecte deux erreurs, expliquez l’origine de ces deux erreurs et  corrigez-les de telle manière que l’affichage console soit identique à celui-ci :

Début du programme.
Interception IndexOutOfRangeException 
Fin du programme.
using System;
 class Action 
 {
 public void meth( )
 {
 throw new DivideByZeroException("calcul impossible");
 throw new IndexOutOfRangeException ("indice hors des limites");
 }
 }
 class Exercice
 {
 public static void Main( ) 
 {
 Action Obj = new Action();
 Console.WriteLine("Début du programme.");
 try
 {
 Obj.meth();
 }
 catch ( IndexOutOfRangeException E )
 {
 Console.WriteLine("Interception IndexOutOfRangeException ");
 }
 catch ( ArithmeticException E )
 {
 Console.WriteLine("Interception ArithmeticException");
 }
 catch (DivideByZeroException E )
 {
 Console.WriteLine("Interception DivideByZeroException ");
 }
 Console.WriteLine("Fin du programme.");
 Console.ReadLine();
 }
 }

Comments are closed, but trackbacks and pingbacks are open.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More