Coffeehouse Post

Single Post Permalink

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

    , Bass wrote

    *snip*

    You can pass value types by reference in C# using the "out" keyword.

    If your reason for doing this is performance, I'd strongly suggest benchmarking first.. that's a pretty controversial assumption you are making about the performance of reference types, especially when going against value types that are 8 or 12 bytes.

    If you're holding instances of the type in a collection, you'd still have to make a local copy when enumerating before you can pass the instance by reference to a method.

    Also I would recommend capital punishment for anyone who uses "Tuple" as a parameter argument in an API. Seems appropriate for the crime.

    Why? void PlotIt(Tuple<int, int, int> xyzCoord) is a self-explanatory method signature. You wouldn't even need to add any comments.