Tuple Types

image Some languages provide a loosely structured way to combine multiple objects (for example, to pass them around in an all-in-one fashion). This comes in handy to overcome the typical single output channel of a method. Output parameters can be used as an alternative to deal with such cases, but they’re more invasive at the method’s call site. When using output parameters, you must introduce local variables and need to specify the out keyword on all such parameters, which can be quite distracting when reading the code:

int res;if (int.TryParse("42", out res))    ...

Tuple types allow multiple objects to be passed around by just wrapping ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.