Quantcast
Channel: Grasshopper - McNeel Forum
Viewing all articles
Browse latest Browse all 39545

Return multiple values from a method : tuple types and tuple literals with Grasshopper C#

$
0
0

@sato wrote:

Hello :slight_smile:

Just a little question for developpers into Grasshopper about syntax:
Is it possible to use c# tuple types and tuple literals into a grasshopper c# component ?

Wich is the version of C# used by grasshopper ? I think it is possible since C#7
I’m using Rhino 5, and Grasshopper Latest Build : 0.9.0076 (Version August 2014)
In Rhino 6 is Grasshopper using the latest C# Version (C#7.1) ?

And I’m afraid that it is too old since C#7 was released in March 2017 (C# Versions dates)

What is the best way for me and my old version to return multiple values types from a Method ?
Like in that exemple ? (wich only works for C#7).

(string, string, string) MyCoolFunction() // tuple return type
{
//…
return (firstValue, secondValue, thirdValue);
}

Wich can be used like this :

var values = MyCoolFunction();
var firstValue = values.Item1;
var secondValue = values.Item2;
var thirdValue = values.Item3;

Have a nice evening/day !
Adrian

Posts: 7

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 39545

Trending Articles