Return multiple values to a method caller
In C# 7 and above, see this answer.
In previous versions, you can use .NET 4.0+'s Tuple:
For Example:
public Tuple<int, int> GetMultipleValue()
{
return Tuple.Create(1,2);
}
Tuples with two values have Item1
and Item2
as properties.
Return multiple values from function
Dart doesn't support multiple return values.
You can return an array,
List foo() {
return [42, "foobar"];
}
or if you want the values be typed use a Tuple
class like the package https://pub.dartlang.org/packages/tuple provides.
See also either
for a way to return a value or an error.
Return multiple values from a class to method
I think create class is better in this case
public class MyClass
{
public string Corrente { get; set; }
public string Temperatura { get; set; }
public string NumGiri { get; set; }
}
then
public MyClass Distri(string inArrivo)
{
// your code
MyClass myclass = new MyClass() {
Corrente = corrente,
NumGiri = numGiri,
Temperatura = temperatura
};
return myclass;
}
this is how you can call
Stripper strp = new Stripper();
MyClass myclass = strp.Distri(invia);
// access values as below
textBox7.Text = myclass.NumGiri;
Getting multiple return values from method
The return value is essentially a Tuple. You can access the data by specifying the names of each value (status, errors, etc.) or accessing them by the returned name.
public extern static (int status, string info) getInfo(string ID);
var (status, info) = getInfo("id");
or
var retVals = getInfo("id");
var status = retVals.status;
var info = retVals.info;
and use the variables like normal.
DisplayStatus(status);
LogInfo(info);
Related Topics
Calling a Function from a String in C#
Does Page Reload Ever Cause Post
How to Deserialize Xml Document
Webbrowser Control in a New Thread
How to Convert a Column Number (E.G. 127) into an Excel Column (E.G. Aa)
Using Setwindowpos With Multiple Monitors
Create a Strongly Typed C# Object from Json Object With Id as the Name
Entity Framework Code First - Two Foreign Keys from Same Table
Addtransient, Addscoped and Addsingleton Services Differences
Difference Between the | and || or Operators
Encrypt and Decrypt a String in C#
Split List into Sublists With Linq
Identify If a String Is a Number
Parameterized Query For MySQL With C#