Generics in C#


using
System;
namespace
Generic
{
class GenericClass<T>
{
public T Getvalue(T input)
{
T obj = input;
return obj;
}

}
public class Test
{
public static void Main()
{
GenericClass<int> objGeneric = new GenericClass<int>();
Console.WriteLine(objGeneric.Getvalue(5));
Console.ReadLine();
}
}
}
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now