How to determine if two generic type values are equal?

前端 未结 7 2217
忘掉有多难
忘掉有多难 2021-02-08 13:29

Update* I am so sorry... my sample code contained an error which resulted in a lot of answers I didn\'t understand. In stead of

Console.WriteLin         


        
7条回答
  •  花落未央
    2021-02-08 13:44

    Line 3 with the generic object is not calling your custom written method. Instead, it is calling the base Object.Equals(object). To call your custom method, you need to pass in a T not a GenericObject. Something like: go1.Equals(go2.Value)

提交回复
热议问题