Sometimes we need a function return multiple values, use the Internet more to achieve out, I personally like to use tuple method.
tuple is a tuple, up to 7 elements, need more nesting methods.
Tuple function is defined as follows:
public static Tuple<string,string> TupleFun() { string[] T = {'hello','world'}; Tuple<string, string> tup = new Tuple<string, string>(T[0], T[2]); return tup; }
Tuple also supports multiple types of values.
public static Tuple<string,int> TupleFun() { string T = ‘hello’; int q = 6; Tuple<string, int> tup = new Tuple<string, int>(T, q); return tup; }
When calling the function, use Item * to call the elements within the tuple.
var tuple = TupleFun(); print(tuple.Item1); print(int.Parse(tuple.Item2));