Generic Operator Overloading : where « Generic « C# / CSharp Tutorial






using System;
using System.ComponentModel;

    class OperatorOverloading
    {
        static bool AreReferencesEqual<T>(T first, T second)
            where T : class
        {
            return first == second;
        }

        static void Main()
        {
            string name = "J";
            string intro1 = "My name is " + name;
            string intro2 = "My name is " + name;
            Console.WriteLine(intro1 == intro2);
            Console.WriteLine(AreReferencesEqual(intro1, intro2));
        }
    }








18.23.where
18.23.1.Use multiple where clauses
18.23.2.where T: struct
18.23.3.Generic Operator Overloading