1
Answer

C# out parameter and dictionary

Amit K

Amit K

8y
414
1

down votefavorite

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)