pruthvi-dumpa-amcs

C#-2

Nov 19th, 2025
160
0
28 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. public class Example
  2. {
  3.     public static void ModifyWithRef(ref int x)
  4.     {
  5.         x += 10;
  6.     }
  7.  
  8.     public static void ModifyWithOut(out int x)
  9.     {
  10.         x = 20;
  11.     }
  12.  
  13.     public static void Main()
  14.     {
  15.         int a = 5;
  16.         ModifyWithRef(ref a);
  17.  
  18.         int b = 5;
  19.         ModifyWithOut(out b);
  20.  
  21.         Console.WriteLine($"Value of a: {a}");
  22.         Console.WriteLine($"Value of b: {b}");
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment