Amit K

Amit K

  • NA
  • 3
  • 5.7k

C# out parameter and dictionary

Jul 6 2016 12:05 PM

I've a dictionary object in my C# code:dictEmployees;--->

It has a list of all Employees.Employee class has two properties...Id and Salary.Lets say, Initially, this collection has a salary of 50K for employee Id 1.

Employee employee = new Employee(); dictEmployees.TryGetValue(1, out employee);

Now,if I modify employee' salary in other some method, I see that the salary is also being reflected in the employee object in the dictionary. Is this expected please?

Thanks.


Answers (1)