Confusion :confused:

ShahzadMughal's Avatar, Join Date: Nov 2008
Light Poster
I couldn't understand the following code specialy underlined area

Code:
using System;

namespace overriding_method
{
    public class MyClass
    {
        public virtual void MethodA<T>(T arg)
            where T : new()
        {
        }
    }

    public class YClass : MyClass
    {
        public override void MethodA<T>(T arg)
        {
            T obj = new T();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {

        }
    }
}
Thanks & Regards
Shahzad
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Its calling the constructor
0
ShahzadMughal's Avatar, Join Date: Nov 2008
Light Poster
where T : new()
ok its calling constructor but who's?
MethodA<T>
why <T> after method name?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You need to get basics of Templating first.