How to return more than one parameter from a function.
Most of us know the vintage way to return these parameters where a parameter is returned and one or more out parameters that contains the other values.
This is poor coding and un easy to read.
This can be fixed by using:
public Tuple<string,int> ReturnTwoParams()
{
Tuple<string, int> retParam =
new Tuple<string,int>("string value", 10);
return retParam;
}
private void Test()
{
Tuple<string, int> retParam = ReturnTwoParams();
string param1 = retParam.param1;
int param2 = retParam.param2;
}
Written by Rudi Roelofse
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#C
Authors
Related Tags
#c
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#