c# – How to return multiple values ​​from a function in C #

Question:

How to return multiple values ​​from a function in C #

Answer:

In order to return several values ​​from a function, you need to declare the required parameters with out modifiers. For instance.

 class SomeClass
 {
    public int getManyData(out object outData1, out object outData2) {
        // Код функции
        outData1 = someValue1; // Необходимо инициализировать выходной параметр
        outData2 = someValue2; // Необходимо инициализировать выходной параметр
        return result;
    }
 }
Scroll to Top