public static void streamReport(this Report report, Stream stream)
{
using (var streamWriter = new StreamWriter(stream))
{
//some logic that calls streamWrite.Write()
streamWriter.Flush();
}
//Should "return stream;" here ?
}
I am writing an extension method to an object in which I would like to transform to a CSV which is generated and returned to a client (web).
My questions are:
- Should I return
stream
(changevoid
toStream
) ? - Should I use the
out
keyword in before theStream
parameter ? Is this a common way to let the caller know the parameter will be changed ? - Should I change the method to generate a new stream (and not accept one) and trust the user to
Dispose
it ? - Should I pass
StreamWriter
instead ofStream
?