Contrainte de constructeur par défaut

Author:

Non,Edité
{filelink=17487}

    using System;

    public class ContrainteConstructeur
    {
        public static void Main()
        {
            Z objet=new Z();
            objet.MéthodeA();
        }
    }

    public class Z
    {
        public void MéthodeA() where T:X, new()
        {
            Console.WriteLine("Z.MéthodeA");
            T objet=new T();
            objet.MéthodeB();
        }
    }

    public class X
    {
        public void MéthodeB()
        {
            Console.WriteLine("X.MéthodeB");
        }
    }

Leave a Reply

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