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 194 views
1 answer 223 views
223 views asked Aug 5, 2014 by avibootz
1 answer 255 views
1 answer 126 views
126 views asked Aug 12, 2021 by avibootz
1 answer 212 views
212 views asked Nov 19, 2023 by avibootz
...