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 13-25 extrait du chapitre La généricité


Exemple 13-24<     > Exemple 13-26


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


Exemple_13_25.cs
using System.Collections.Generic;
class C<T> {
   public void Fct(T t){
      int = as int; // Erreur de compilation: 
                // The as operator must be used with a reference type.
      string = as string;
      if( s!= null ) { /*...*/ } 
      if( t is IEnumerable<int> ){
         IEnumerable<int> enumerable = as IEnumerable<int>;
         foreachint in enumerable) { /*...*/ }
      }
   }
}	
Copyright Patrick Smacchia 2006 2007