How to use ref keyword in C#

1 Answer

0 votes
using System;

class Program
{
    public static void ProcessNumber(ref int num) {
        num = 999;
    }     
    static void Main() {
        int x = 3;

        ProcessNumber(ref x); 
           
        Console.WriteLine(x);
    }
}




/*
run:
  
999
  
*/

 



answered Aug 12, 2021 by avibootz

Related questions

2 answers 320 views
1 answer 306 views
306 views asked Aug 5, 2014 by avibootz
1 answer 338 views
1 answer 213 views
213 views asked Aug 12, 2021 by avibootz
1 answer 298 views
298 views asked Nov 19, 2023 by avibootz
...