Will GetHashCode turn into a box construct when used as a key in a dictionary?

Usually, if a structure implements an interface, assigning such a structure to an interface variable causes a box, for example:

interface IFoo {}

struct S : IFoo {}

S s = ...
IFoo f = s; // boxing here

However, there are exceptions. It seems that the implementation IEquatable<T>and use of such a structure in the dictionary as a key will not lead to boxing. So the question is, what if I just redefine GetHashCodewithout implementation IEquatable<T>? Will he fall into some special case?

+4
source share
1 answer

IEquatable<T>, Equals. Equals .

+1

Source: https://habr.com/ru/post/1533803/


All Articles