[personal profile] finesoul

In my example ExternalRefId is unique. That's why other fields (i.e. ExternalRefValue :) are ignored.




  1. public struct ReconcileInfo

  2. {

  3.     public string ExternalRefValue;

  4.     public int ExternalRefId;

  5.  

  6.  

  7.     /// <summary>

  8.     /// Initializes a new instance of the <see cref="ReconcileInfo"/> struct.

  9.     /// </summary>

  10.     /// <param name="externalRefId">The external ref id.</param>

  11.     /// <param name="externalRefValue">The external ref value.</param>

  12.     public ReconcileInfo(int externalRefId, string externalRefValue)

  13.     {

  14.         ExternalRefId = externalRefId;

  15.         ExternalRefValue = externalRefValue;

  16.     }

  17.  

  18.     /// <summary>

  19.     /// Implements the operator ==.

  20.     /// </summary>

  21.     /// <param name="left">The left.</param>

  22.     /// <param name="right">The right.</param>

  23.     /// <returns>

  24.     /// The result of the operator.

  25.     /// </returns>

  26.     public static bool operator ==(ReconcileInfo left, ReconcileInfo right)

  27.     {

  28.         return left.ExternalRefId == right.ExternalRefId;

  29.     }

  30.  

  31.  

  32.     /// <summary>

  33.     /// Implements the operator !=.

  34.     /// </summary>

  35.     /// <param name="left">The left.</param>

  36.     /// <param name="right">The right.</param>

  37.     /// <returns>

  38.     /// The result of the operator.

  39.     /// </returns>

  40.     public static bool operator !=(ReconcileInfo left, ReconcileInfo right)

  41.     {

  42.         return !(left == right);

  43.     }

  44.  

  45.  

  46.  

  47.     /// <summary>

  48.     /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.

  49.     /// </summary>

  50.     /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>

  51.     /// <returns>

  52.     ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.

  53.     /// </returns>

  54.     public override bool Equals(object obj)

  55.     {

  56.         if (!(obj is ReconcileInfo))

  57.         {

  58.             return false;

  59.         }

  60.         ReconcileInfo objAsStruct = (ReconcileInfo)obj;

  61.         return objAsStruct.ExternalRefId == this.ExternalRefId;

  62.  

  63.     }

  64.  

  65.     /// <summary>

  66.     /// Returns a hash code for this instance.

  67.     /// </summary>

  68.     /// <returns>

  69.     /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

  70.     /// </returns>

  71.     public override int GetHashCode()

  72.     {

  73.         return this.ExternalRefId.GetHashCode();

  74.     }

  75. }




Лютий 2022

Н П В С Ч П С
  12345
6789101112
13141516171819
202122232425 26
2728     

За стиль дякую

Створено з Dreamwidth Studios
Сторінка створена 2025-Лип-06, Неділя 07:03