If I just need to create an instance of the class to call one method on it, and then do with it, I like to do it on one line, for example,
string result = new MyClass().GetResult();
Instead of doing something like
var myClass = new MyClass(); string result = myClass.GetResult();
I understand that the same thing happens behind the scenes in terms of memory allocation and subsequent cleanup. Is this true or is there a difference? And if so, is it more effective than the other?
EDIT:
Creating a static method, as many of you have suggested, is a good solution. I am working with a class that someone else created that I cannot reorganize or change at the moment. So, for such a situation, is there any difference in creating an instance of a row or a single row?
EDIT:
Does the answer to this question depend on the amount of resources supported by the class (from the comments of Blam and BenCr below)?
source share