using System;public class Student {public int Id {get;set;}public string Name {get;set;}}public class Program {public static void Main() {var s1 = new Student(){Id = 1, Name = "Ram"};var s2 = new Student();s2 = s1;s2.Id = 2;s2.Name = "Shyam";Console.WriteLine("Id:" + s1.Id + " , Name:" + s1.Name);}}
Interviews2 answers
What is the output of the below program?
2 Answers
Id: 2 , Name: Shyam
Mani VangaraPosted Nov 10, 2022, 4:29 PM EST
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.
Nabaraj GhimirePosted Aug 18, 2022, 12:40 PM EDT

