This is a prototypical generic method: : Generic Method « Generics « C# / C Sharp






This is a prototypical generic method:

 

using System;


public class Starter {
    public static void Main() {
        MyClass.MethodA<int>(20);
    }
}

public class MyClass {
    public static void MethodA<T>(T param) {
        Console.WriteLine(param.GetType().ToString());
    }
}

 








Related examples in the same category

1.Demonstrate a generic methodDemonstrate a generic method
2.A prototypical generic methodA prototypical generic method
3.Generic methods can overload nongeneric methodsGeneric methods can overload nongeneric methods