While working with PHP I used output buffer as a way to "combine" multiple method outputs and ex. write buffet to a file.
Example:
ob_start();
print $foo->bar();
print $anotherFoo->anotherBar();
$output= ob_get_contents();
ob_end_clean();
file_put_contents("output.html",$output);
Is there an equivalent in C#?