I have a tendency to invoke methods directly on a new class instance like this:
new Person().GetAge()
when I don't need the instance of the class (here Person) after the invocation.
However, I have seen many developers recommend using this pattern:
Person p = new Person();
p.GetAge()
What are the benefits of declaring a local variable if the instance it references is not required after a method call?
Note: I know in some cases, such methods can be changed to static methods, but for now assume that is not possible?
new Person("id:34fg76").GetAge()