Home
Browsez les 647 exemples
Téléchargez les 647 exemples
Téléchargez des chapitres
Achetez sur amazon.fr

Niveau: Débutant/Intermédiaire
ISBN-2-84177-339-6
50 Euros

Exemple 11-11 extrait du chapitre Notions de classe et d'objet


Exemple 11-10<     > Exemple 11-12


Cet exemple peut être compilé avec la ligne de commande:
csc.exe /target:exe Exemple_11_11.cs
Erreurs: 0 Avertissements: 0
Remarque:


Exemple_11_11.cs
using System;
class Program {
   static void Main() {
      fct("Appel1");
      fct("Appel2"673.1415"hello"8);
      fct("Appel3""bonjour"2.71729691"au revoir");
   }
   static void fct(string str, params object[] args) {
      Console.WriteLine(str);
      foreach (object obj in args) {
         if (obj is intConsole.WriteLine(" int:" + obj);
         else if (obj is doubleConsole.WriteLine(" double:" + obj);
         else if (obj is stringConsole.WriteLine(" string:" + obj);
         else Console.WriteLine(" autre type:" + obj);
      }
   }
}	
Copyright Patrick Smacchia 2006 2007