Per Erik Strandberg /cv /kurser /blog

It if of course simple to to generic methods - I just have not seen many.

using System;

namespace Csharp Generic Method Test
{
    class Program
    {
        static void PrintMe<T>(T item)
        {
            Console.WriteLine(item.ToString());
        }


        static void Main(string[] args)
        {
            int i = 0;
            string s = "foobar";

            PrintMe<int>(i);
            PrintMe<string>(s);

            Console.WriteLine("Press any key to continue. . .");
            Console.ReadKey(true);
        }
    }
}


Tillhör Kategori Programmering.