How to use a same StreamWriter across various methods in a class. For eg.
public class XMLWriter
{
public export(string filename)
{
StreamWriter sw = new StreamWriter(filename)
sw.write("Line1")
}
public footer()
{
// Note: I am not declaring streamwriter here since i want to use the same sw as in export method
sw.write("Line x N")
}
}
How can I use the same sw across many methods. Also this class will be instantiated from another class and the "public" methods will be called from there.
Any help will be highly appreciated.