Generic methods can overload nongeneric methods : Generic Method « Generics « C# / C Sharp






Generic methods can overload nongeneric methods

Generic methods can overload nongeneric methods

using System;

public class Starter{
        public static void Main(){
            MethodA(5);
            MethodA(5.0);
        }
        public static void MethodA<T>(T arg) {
            Console.WriteLine("ZClass.MethodA(T arg)");
        }

        public static void MethodA(int arg) {
            Console.WriteLine("ZClass.MethodA(int arg)");
        }

        public static void MethodA() {

            Console.WriteLine("ZClass.MethodA()");
        }
}

           
       








Related examples in the same category

1.This is a prototypical generic method:
2.Demonstrate a generic methodDemonstrate a generic method
3.A prototypical generic methodA prototypical generic method