I want to write a function that will print a sentense to FILE or CONSOLE
look like below
using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Try
{
class Program
{
static void Main(string[] args)
{
using (FileStream OutputFile = new FileStream("ABC .txt",
FileMode.Create , FileAccess.Writ e, FileShare.None) )
{
using (StreamWriter OutputBodyWrite r = new
StreamWriter(Ou tputFile))
{
PrintLine(Syste m.Console); // *************** ***How can
i use console as a parameter?
PrintLine(Outpu tBodyWriter);
OutputBodyWrite r.Close();
}
OutputFile.Clos e();
}
} // end Main
public static void PrintLine(Strea mWriter OutputDevice)
{
OutputDevice.Wr iteLine("Wellco me to test program");
}
}
} // end program
*** PrintLine(Syste m.Console); // *************** ***How can i use console as
a parameter?
Is it possible? I am newbie of C#
If it is possible, but the above program goes to wrong way, let me know too
Thanks
look like below
using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Try
{
class Program
{
static void Main(string[] args)
{
using (FileStream OutputFile = new FileStream("ABC .txt",
FileMode.Create , FileAccess.Writ e, FileShare.None) )
{
using (StreamWriter OutputBodyWrite r = new
StreamWriter(Ou tputFile))
{
PrintLine(Syste m.Console); // *************** ***How can
i use console as a parameter?
PrintLine(Outpu tBodyWriter);
OutputBodyWrite r.Close();
}
OutputFile.Clos e();
}
} // end Main
public static void PrintLine(Strea mWriter OutputDevice)
{
OutputDevice.Wr iteLine("Wellco me to test program");
}
}
} // end program
*** PrintLine(Syste m.Console); // *************** ***How can i use console as
a parameter?
Is it possible? I am newbie of C#
If it is possible, but the above program goes to wrong way, let me know too
Thanks
Comment