Coffeehouse Post

Single Post Permalink

View Thread: How are you using Tuple in code?
  • User profile image
    cbae

    , evildictait​or wrote

    The only time I ever use it is as a generic argument, where I'd really like two things instead of one generic argument.

    For example, a List<Tuple<string, int>> or an GenericEventArgs<Tuple<string, TcpClient>> or some such.

    Instead of List<Tuple<string,int>>, I'd probably use Dictionary<string,int> if the string element needed to be unique.

    I would most likely use Tuple<int,int> for managing data for 2D graphing. The benefit is that it's a reference type, whereas something like System.Drawing.Point is a value type, and passing the Tuple object as an argument to methods is more efficient.

    If you're doing 3D surface modelling, then Tuple<int, int, int> is the only way to go.