constrained method calls : Generic Method : Generic C# Examples


C# Examples » Generic » Generic Method »

 

constrained method calls









    
using  System;
using  System.Collections.Generic;
using  System.Diagnostics;
using  System.Runtime.CompilerServices;

public  class  MainClass
{
        static  string  GetToString<T>(T  input)
        {
                return  input.ToString();
        }
        public  static  void  Main()
        {
                Console.WriteLine(GetToString<int>(10));

        }
}
    
   
  
   



Output

10


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic Method