I'm interested: What is C#'s analog of std::pair
in C++? I found System.Web.UI.Pair
class, but I'd prefer something template-based.
Thank you!
I'm interested: What is C#'s analog of std::pair
in C++? I found System.Web.UI.Pair
class, but I'd prefer something template-based.
Thank you!
Unfortunately, there is none. You can use the
System.Collections.Generic.KeyValuePair<K, V>
in many situations.Alternatively, you can use anonymous types to handle tuples, at least locally:
The last alternative is to create an own class.
On order to get the above to work (I needed a pair as the key of a dictionary). I had to add:
and once I did that I also added
to suppress a compiler warning.