# Protocol as Dictionary Key or Set element

**URL:** <https://forums.swift.org/t/protocol-as-dictionary-key-or-set-element/80075>\
**Category:** Using Swift\
**Tags:** collection, learning, protocol\
**Created:** [May 23, 2025, 8:14am UTC](https://forums.swift.org/t/protocol-as-dictionary-key-or-set-element/80075 "2025-05-23T08:14:38Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [May 23, 2025, 3:30pm UTC](https://forums.swift.org/t/protocol-as-dictionary-key-or-set-element/80075/17 "2025-05-23T15:30:15Z")

</div>

> [@Danny](#):
>
> I think I understand conceptually why it _doesn't_ work, in Swift, this was also not enough to help me understand why it _does_ work in C# (maybe understanding the difference would help the OP with the Swift):

> [@Why can't I use existential type for placeholder in generic type?](https://forums.swift.org/t/why-cant-i-use-existential-type-for-placeholder-in-generic-type/74257/18):
>
> In C#, you would not be able to use the equivalent of FixedWidthInteger as a type. C# observes the invariant that any interface used as a type (i.e., existential) must satisfy itself as a constraint (i.e., conform to itself)—as Slava explained—and enforces this at the language level. (This does imply, unless I’m mistaken, that semantic guarantees not expressed in code cannot be enforced.) Until later versions, C# did not support static abstracts in interfaces (i.e., static requirements witho…

---

_[View the full topic](https://forums.swift.org/t/protocol-as-dictionary-key-or-set-element/80075)._
