<oembed><type>rich</type><version>1.0</version><title>codementor wrote</title><author_name>codementor (npub1u6…v0yg2)</author_name><author_url>https://yabu.me/npub1u69qs4hfpkve0v0hy85s2fycjeqjm4ts8xdfs7ew3l270l87yfuspv0yg2</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>Learn: Never change a key while it is in a HashSet&#xA;&#xA;A HashSet or Dictionary files each key by its hash code. If the key changes, its hash code changes, and the set looks in the wrong place.&#xA;&#xA;```csharp&#xA;var p = new Point { X = 1 };&#xA;var set = new HashSet&lt;Point&gt; { p };&#xA;p.X = 2; // changes p&#39;s hash code&#xA;Console.WriteLine(set.Contains(p));&#xA;```&#xA;&#xA;It prints False, even though p is in the set. Use keys that can&#39;t change, like strings, numbers or records without setters.&#xA;&#xA;#tip · TIP-012</html></oembed>