Categories
Mastering Development

How bad is using pass by references in c#?

public class HouseService { public void CreateHouse() { var house = new House() { Things = new List<Thing>() }; this.AddThings(house); } //Using Pass By reference concept public void AddThings(House house) { //Adding Things here house.Things.Add(new Thing()); } //Returning List<Thing> from AddThings Method public List<Thing> AddThings(int houseId) { var things = new List<Thing>(); things.Add(new Thing()); return […]