Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting multiple return values from method

I’m trying to use a library and the below code is its documentation about the method that I’ll have to call

public extern static (int status, string info) getInfo(string ID); 

My question is, how can I get the return value form this method ? I can call the method and pass in the parameters but I don’t know how to get the return values since they are multiple.

Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading