class Program
{
// Example of a reference type: a simple class
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public Person(string name, int age)
{
Name = name;
Age = age;
}
}
static void Main()
{
// Creating an instance of the reference type (Person)
Person person1 = new Person("John Doe", 25);
// Creating another reference (person2) pointing to the same object as person1
Person person2 = person1;
// Modifying the object through one reference affects the other reference
person1.Age = 30;
// Both references point to the same object, so both will reflect the change
Console.WriteLine($"person1: {person1.Name}, Age: {person1.Age}");
Console.WriteLine($"person2: {person2.Name}, Age: {person2.Age}");
}
}