Veikedo

first one

Dec 7th, 2020 (edited)
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. // What will be the output in console?
  2. using System;
  3.  
  4. public class User
  5. {
  6.     public string Name { get; }
  7.     public User(string name)
  8.     {
  9.         this.Name = name;
  10.     }
  11. }
  12.  
  13. public class Program
  14. {
  15.     public static void ChangeUser(User u)
  16.     {
  17.         u = new User("User 2");
  18.     }
  19.  
  20.     public static void Main()
  21.     {
  22.         var user = new User("User 1");
  23.         ChangeUser(user);
  24.  
  25.         Console.WriteLine(user.Name);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment