Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemples des champs génériques

Non,Edité
{filelink=17495}

using System;
using System.Collections.Generic;
using System.Text;
 
class MesChampsGeneriques<T, U>
{
    private T premierChamps;
    private U secondChamps;
 
    public MesChampsGeneriques(T val1, U val2)
    {
        this.premierChamps = val1;
        this.secondChamps = val2;
    }
 
    public T ObtenirValeurPremierChamp()
    {
        return this.premierChamps;
    }
 
    public U ObtenirValeurSecondChamp()
    {
        return this.secondChamps;
    }
}
 
class MyApp
{
    static void Main(string[] args)
    {
        MesChampsGeneriques<string, string> expType = new MesChampsGeneriques<string, string>("MesExemple.com", "Java");
        Console.WriteLine(expType.ObtenirValeurPremierChamp());
        Console.WriteLine(expType.ObtenirValeurSecondChamp());
    }
}

No comments yet.

Leave a Comment