Bonjour
Je voudrais faire quelque chose comme suit :
est ce possible ?

c'est à dire appeler une méthode avec un generic , et instancier dans la méthode un autre généric T1, qui sera passé à une autre méthode

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
 public static class TestClass
    {
        public static void Process<T>(T p)
        {
            //I would like to do sommething like this
            T1 anotherGeneric = typeof(AnotherClass);
 
            InnerProcess<T1>();
 
        }
 
        private static void InnerProcess<T>()
        {
            throw new NotImplementedException();
        }
    }
 
    public class AnotherClass
    {
    }
 
static void Main(string[] args)
        {
            TestClass.Process<string>("test");
        }
Merci