Tuples - Getting more for your money !?
Posted: Fri Mar 24, 2017 3:03 pm
Hi guys,
In following up my Generics research work at the moment, I came across 'Tuples'.
Yes, apparently 'Tuples' are seen as the new sexy thing in C#, for a lot of folks that is.
Now that we have in our xBase armoury all that C# con do, I thought I would digress from my Generics for a moment, and have a look at the syntax required within X# for Tuple use.
It seems like Tuples (structures) can be used simply when we need to return from a method (for example) more than one item of data - more than one value, object or collections.
Have any of you started to use Tuples ? And if so have you any nice examples you can share with the rest of the X# Forum ?
Here below are some images of Tuples - details and working code in use :-
Yes, 'Items' are what are within Tuples - Item1, Items2, ........ etc.
Now a little test of my own making :-
After seeing the definition above, lets now see some testing code using the structure :-
The notes in MSDN show how many variations of Tuples that we can have :-
And here is some detail of just one of those, it is that for three items :-
Can anyone take us further with Tuples and their use - and - can any one warn us about "over-use", you know, the sort of things we all do when finding something new.
I think the phrase is something along the lines of "... when what you have in your hand is a hammer, everything looks like a nail ..."
Remember Interfaces ??? They got a bit 'done to death' as I recall ;-0)
Any contributions - good, bad, verbal, visual etc., etc.. ???
Cheers, and Best regards,
Phil.
Wales, UK.
In following up my Generics research work at the moment, I came across 'Tuples'.
Yes, apparently 'Tuples' are seen as the new sexy thing in C#, for a lot of folks that is.
Now that we have in our xBase armoury all that C# con do, I thought I would digress from my Generics for a moment, and have a look at the syntax required within X# for Tuple use.
It seems like Tuples (structures) can be used simply when we need to return from a method (for example) more than one item of data - more than one value, object or collections.
Have any of you started to use Tuples ? And if so have you any nice examples you can share with the rest of the X# Forum ?
Here below are some images of Tuples - details and working code in use :-
Yes, 'Items' are what are within Tuples - Item1, Items2, ........ etc.
Now a little test of my own making :-
After seeing the definition above, lets now see some testing code using the structure :-
The notes in MSDN show how many variations of Tuples that we can have :-
And here is some detail of just one of those, it is that for three items :-
Can anyone take us further with Tuples and their use - and - can any one warn us about "over-use", you know, the sort of things we all do when finding something new.
I think the phrase is something along the lines of "... when what you have in your hand is a hammer, everything looks like a nail ..."
Remember Interfaces ??? They got a bit 'done to death' as I recall ;-0)
Any contributions - good, bad, verbal, visual etc., etc.. ???
Cheers, and Best regards,
Phil.
Wales, UK.