Nabaraj Ghimire
What is the output of the below program?
  1. using System;
  2. public class Student {
  3. public int Id {get;set;}
  4. public string Name {get;set;}
  5. }
  6. public class Program {
  7. public static void Main() {
  8. var s1 = new Student(){Id = 1, Name = "Ram"};
  9. var s2 = new Student();
  10. s2 = s1;
  11. s2.Id = 2;
  12. s2.Name = "Shyam";
  13. Console.WriteLine("Id:" + s1.Id + " , Name:" + s1.Name);
  14. }
  15. }
By Nabaraj Ghimire in .NET on Aug 18 2022
  • Nabaraj Ghimire
    Aug, 2022 18

    The output is:- Id:2 , Name:Shyam

    The aim of this question is to test the fundamental concept of reference type of object in C#. Here s1 and s2 are pointing the same location of a memory.

    • 6
  • Mani Vangara
    Nov, 2022 10

    Id: 2 , Name: Shyam

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS