> For the complete documentation index, see [llms.txt](https://til.cazzulino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.cazzulino.com/dotnet/using-hashcode-in-.netframework.md).

# Using HashCode in .NETFramework

So, I just learned that not even in .net472/net48, you can leverage the cool [HashCode](https://github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/shared/System/HashCode.cs) type from .NETCore. It **is** [mentioned in docs](https://docs.microsoft.com/en-us/dotnet/api/system.hashcode?view=dotnet-plat-ext-3.1) as available in ".NET Platform Extensions 3.1", which isn't quite clear what it means. After a quick search here and there, I found out the [Microsoft.Bcl.HashCode](https://www.nuget.org/packages/Microsoft.Bcl.HashCode/) package, which seems to be one such ".NET platform extension" (although the version # doesn't match either :/).

With that, I can now make a `KeyValuePairComparer<TKey, TValue>`to check for dictionaries equality like:

```
	public class KeyValuePairComparer<TKey, TValue> : IEqualityComparer<KeyValuePair<TKey, TValue>>
	{
		public static KeyValuePairComparer<TKey, TValue> Default { get;} = new KeyValuePairComparer<TKey, TValue>();
		
		public bool Equals(KeyValuePair<TKey, TValue> x, KeyValuePair<TKey, TValue> y) => object.Equals(x.Key, y.Key) && object.Equals(x.Value, y.Value);

		public int GetHashCode(KeyValuePair<TKey, TValue> obj) => HashCode.Combine(obj.Key, obj.Value);
	}
```

To be used as:

```
IReadOnlyDictionary<string, string> first = ...
IReadOnlyDictionary<string, string> second = ...

return first.SequenceEquals(second, KeyValuePairComparer<string, string>.Default);

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://til.cazzulino.com/dotnet/using-hashcode-in-.netframework.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
