stackoverflow1453

Programming&&Games&&Life

Generic Classes – 2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _09_06_2017_b
{
    class Test<T>
    {
        T _value;

        public Test(T t)
        {
            this._value = t;
        }

        public void Write()
        {
            Console.WriteLine(this._value);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Test<int> t1 = new Test<int>(5);
            t1.Write();

            Test<string> t2 = new Test<string>("Alo");
            t2.Write();

            Test<double> t3 = new Test<double>(4.5);
            t3.Write();

            Console.ReadKey();
        }
    }
}
Advertisements

No comments yet»

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: