(Leveraging C# 7 Tuple, How to ‘stream’ API result to the client using tuple)

Make the C# tuple great again

Tuples were available before C# 7, but they were inefficient and had no language support. This meant that tuple elements could only be referenced as Item1 , Item2 and so on. C# 7 introduces language support for tuples, which enables semantic names for the fields of a tuple using new, more efficient tuple types.

I used tuples before C# 7. I have to admit that those Item1 , Item2 were weird.

Supposed that your customer asked you to build a public API that consume another secret API. One of its endpoint has the following requirements:

The secret API requires some extra parameters as the request payload.

Generate those secret parameters based on public API request payload.

Send back the secret API status code and its response to the public API as is.

The last one sounds like a good candidate for a tuple!

Let G̷a̷r̷b̷a̷g̷e̷ ̷C̷o̷l̷l̷e̷c̷t̷ alone the first two requirements since it is not related to the tuples.