Over the past few years under the “new Microsoft”, there have been many efforts to open-source the languages and frameworks that Microsoft develop. .NET Core (Microsoft’s development platform) is fully open-source and developers are actively encouraged to develop applications on non-Windows platforms such as Linux and macOS, something that wouldn’t have happened at all during the previous administration.
Anyway, I write this article while developing in Visual Studio Code on macOS and I came across a new C# feature that serves no other purpose than to put a smile on developers faces all around the globe: Value Tuples.
Why should I care?
How many times have you needed to return 2 or more values from a method? Take this example:
I need a method that generates a partition key and row key for a database from a given input value.
There are a few ways of doing this before tuple values came along. And, none of them are particularly pretty.
Out Parameters
A favourite of C/C++ developers, out
parameters give you the ability to return values through method parameters (as opposed to using parameters for inputs).
public string GenerateKeys(string input, out string…