Equality of two structs in C#

前端 未结 6 857
独厮守ぢ
独厮守ぢ 2020-12-17 21:15

I look for an equality between two instances of this struct.

public struct Serie
{
    T[]         X; 
    double[]    Y;

    public Serie(T[] x, d         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-17 21:41

    You should compare the contents of the Array in your Equality logic ...

    Also, it is recommended that you implement IEquatable interface on your struct, as this prevents boxing/unboxing issues in some cases. http://blogs.msdn.com/jaredpar/archive/2009/01/15/if-you-implement-iequatable-t-you-still-must-override-object-s-equals-and-gethashcode.aspx

提交回复
热议问题