When to return 'this' instead of 'void' in a method and why?
问题 What are the benefits (or drawbacks) of returning a reference to 'this' object in a method that modifies itself? When should returning a 'this' be used as apposed to void? When looking at an answer on code review stack exchange, I noticed that the answer used a 'return this' in a self operating method. Simplified class from original: class Item { public Item(string name) { Name = name; } public string Name { get; private set; } public Item AddComponent(ItemComponent component) { _components