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
Jimmacle
Jimmacle4mo ago
object and pattern matching?
Claudiu HBann
Claudiu HBannOP4mo ago
what do you mean by pattern matching? checking for the object's type?
Jimmacle
Jimmacle4mo ago
basically, yes what problem are you trying to solve?
Claudiu HBann
Claudiu HBannOP4mo ago
are any popular libraries that mimics the most C++ STL containers?
Jimmacle
Jimmacle4mo ago
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
Jimmacle
Jimmacle4mo ago
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
Claudiu HBann
Claudiu HBannOP4mo ago
i dont have a specific problem, i was ust curious
Omnissiah
Omnissiah4mo ago
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.
Want results from more Discord servers?
Add your server