Avatar ·

How to return multiple values from a method in C#?

Hello everyone! I'm a beginner C# developer and I've encountered a problem: I need a method to return multiple values at once. For example, I'm writing a method that calculates the minimum and maximum value in an array, and I want to get both results. Currently, I'm doing it like this: ```csharp public void FindMinMax(int[] numbers, out int min, out int max) { min = numbers[0]; max = numbers[0]; foreach (int num in numbers) { if (num < min) min = num; if (num > max) max = num; } } ``` But this looks cumbersome, especially when there are many parameters. Plus, I've heard that `out` is not the best style. Can you advise how to properly return multiple values from a method? Are there any modern approaches used in real projects? Thanks in advance!