How to use out keyword in C#

1 Answer

0 votes
using System;

class Program
{
    public static void GetRandomValue(out int x, out int y) {
        var random = new Random();
        
        x = random.Next(10000, 99999);
        y = random.Next(10000, 99999);
    } 
    static void Main() {
        int a, b;
        
        GetRandomValue(out a, out b);

        Console.WriteLine($"{a}, {b}");
    }
}




/*
run:
  
75397, 37400
  
*/

 



answered Aug 12, 2021 by avibootz

Related questions

1 answer 224 views
224 views asked Aug 12, 2021 by avibootz
2 answers 339 views
2 answers 295 views
2 answers 348 views
1 answer 306 views
306 views asked Aug 5, 2014 by avibootz
...