Exemples des champs génériques

Author:

Non,Edité
{filelink=17495}

using System;
using System.Collections.Generic;
using System.Text;

class MesChampsGeneriques
{
    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 expType = new MesChampsGeneriques("MesExemple.com", "Java");
        Console.WriteLine(expType.ObtenirValeurPremierChamp());
        Console.WriteLine(expType.ObtenirValeurSecondChamp());
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *