CSharp's C++ std::variant
Is there a std::variant in C# like in C++?
If not what is the closest thing to it?
8 Replies
object
and pattern matching?what do you mean by pattern matching?
checking for the object's type?
basically, yes
what problem are you trying to solve?
are any popular libraries that mimics the most C++ STL containers?
i don't know of any, i use C# standard containers
the names are different but there are lots that work the same as STL containers
for variant specifically you could look at https://github.com/mcintyre321/OneOf
GitHub
GitHub - mcintyre321/OneOf: Easy to use F#-like ~discriminated~ uni...
Easy to use F#-like ~discriminated~ unions for C# with exhaustive compile time matching - mcintyre321/OneOf
i dont have a specific problem, i was ust curious
just to give choice theres also dunet
https://github.com/domn1995/dunet
GitHub
GitHub - domn1995/dunet: C# discriminated union source generator
C# discriminated union source generator. Contribute to domn1995/dunet development by creating an account on GitHub.