Нашли или выдавили из себя код, который нельзя назвать нормальным,
на который без улыбки не взглянешь?
Не торопитесь его удалять или рефакторить, — запостите его на
говнокод.ру, посмеёмся вместе!
/// <summary>
/// Calculates and returns a hashcode based on this user's
/// MarketName and default units. The hashcode should be
/// unique for each different combination of MarketName and
/// units.
/// </summary>
/// <returns>An int that may be positive or negative.</returns>
public override int GetHashCode()
{
// A function like this raises innumerable questions. Why did they over ride the
// hash code function? Why did they use an attribute that is not certain to be unique?
// why did they not use the one that is going to be unique? Why did they not cvheck to
// see if the thing they were hasing was not null? When did my life go so far off the rails
// that I have to deal with code like this? How many places call this code? Why did they not
// include any meaningful comments? Why does it suddenly start breaking after the 3.5 upgrade?
// in an effort to avoid thinking about those questions, I've justy changed the has to use the
// unique user id instead of the retarded defaultuserunits hash.
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(this.MarketName);
if (this.DefaultUserUnits != null)
{
sb.Append(Utility.StringUtility.GetJSObjectLiteral(this.DefaultUserUnits));
}
else
{
sb.Append(Utility.StringUtility.GetJSObjectLiteral(this.ID));
}
return sb.ToString().GetHashCode();
}
Автору сего гк обязательно к ознакомлению! Особенно обратить внимание на то, что String.GetHashCode может возвращать разные значения в разных версиях рантайма.
э$K"D?D.A)Q.G"N:U"U:Q J?S!Z?I"R,H!Q?WA(U"V.H$P?B.G.A?K.S$F(X)M.D.A$R,GF.ZVN Q$Y I R!L:H(S?E:U!BA(Y)M(G"X"R(U.I:P$M"F(H(U.D)P,K)R!N)F:M:V:Q,M?K.G P(Z?Z!D:H"Z"I,U)M!G:N:G Y W$Z$K P:Y"G?R!P,S(H,C,F!K"V,H)H.P!S"S?T(Q)DФBNFLIOJFHOAHPTVWIOKFMQBCLBCFWELFUQENRLYDSACDCBVISISL
Был бы это нормальный форум, расписал бы. А так просто приведу ссылку: Автору сего гк обязательно к ознакомлению! Особенно обратить внимание на то, что String.GetHashCode может возвращать разные значения в разных версиях рантайма.
и какое имеет значение что в разных версиях - разный результат? Они же не пароль хешируют для хранения в базе.