Generic methods

Generic method is a method with generic type.

 
using System;

class Test
{
    static void print<T>(T t)
    {
        Console.WriteLine(t);
    }

    static void Main()
    {
        print(3);
        print("java2s . com");
    }
}

The output:


3
java2s . com
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.