I misread your question here is my updated solution.
when you create an instance of the class with
new
keyword it creates a new instance and new memory block for that instance hence it can have different values for the same member of the class.
in detail
class Student
{
public string StudentName = string.Empty;
public int Age = 0;
}
class StudentManager
{
public void ManageStudents()
{
Student student1 = new Student();
student1.Name = "Student 1";
Student student2 = new Student();
student2 .Name = "Student 2";
int age = 10;
Console.WriteLine(student1.Age);
ChangeStudentName(student1,age);
Console.WriteLine(student1.Age);
}
private ChangeStudentAge(Student student,int newAge)
{
student.Age= newAge;
newAge = 100;
}
}