Could you describe what generic type inference is and what will be the output of this program?

    class Program
    {
        static void SomeMethod(object parameter)
        {
            Console.WriteLine("Hello");
        }

        static void SomeMethod<T>(T parameter)
        {
            Console.WriteLine("World");
        }

        static void Main(string[] args)
        {
            object obj = "x";
            string s = "x";
            SomeMethod(obj);
            SomeMethod(s);
        }
    }
}

Experience Level: Not defined
Tags: .NETC#Code challenge

Answer

Comments

No Comments Yet.
Be the first to tell us what you think.
.NET challenge
.NET challenge

Are you learning C# ? Try our test we designed to help you progress faster.

Test yourself