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 – Types partiels

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



Le programme de gauche comporte des erreurs, décelez-les et corrigez-les. N’utiliser le compilateur C# qu’en dernier recours si vous n’avez pas trouvé, ou bien pour vérifier vos hypothèses. Votre correction ne doit pas modifier l’instruction suivante :
Console.WriteLine( “obj1.x = “+obj1.x+” , obj2.x = “+obj2.x +” , obj3.x = “+obj3.x );

Après correction et exécution le programme devra afficher :

using System;
 class Exercice
 {
 public static void Main( ) 
 {
 ClasseA obj0 = new ClasseA ( );
 ClasseA obj1 = new ClasseB ( );
 ClasseA obj2 =(ClasseA) obj1;
 ClasseB obj3 = (ClasseB) obj1;
 Console.WriteLine( "obj1.x = "+obj1.x+" , obj2.x = "+obj2.x +" , obj3.x = "+obj3.x );
 Console.ReadLine( );
 }
 }
 partial class ClasseA 
 {
 public static int x = 100;
 }
 abstract partial class ClasseA 
 {
 public int y = 200;
 }
 internal partial class ClasseA 
 {
 public int z = 300;
 }
 partial class ClasseB :ClasseA 
 {
 public int x = 1000;
 }

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