Is there any performance hit or memory consumption difference to creating a temporary variable in a function compared to returning directly the value assigned to this variable?
For example, which of these functions (GetValue) are better in performance and for saving memory or both are exactly the same:
Case 1:
private string GetValue()
{
return this.GetResult();
}
private string GetResult()
{
// Code here that return a big string...
}
Case 2:
private string GetValue()
{
string result = this.GetResult();
return result;
}
private string GetResult()
{
// Code here that return a big string...
}
Thank you.