I have this weird problem where I have to set the console parameters like the title , backcolor , forecolor ... and don't want to do it over and over. So I want to make a class that has a method that does it for me in another project . The why is not so important, I basically want to make common code to share between projects.
Something like :
// Console type project :
public static class Program
{
public static void Main()
{
SetConsoleParameters(this.Console);
}
}
// Class library
public class SomeLibrary()
{
public Console SetConsoleParameters(Console console)
{
console.Title = "Nice title";
console. // Etc...
}
}
I know you can't pass a static class like the console as a parameter and you can't access the console by with this
but is it somehow possible to set things up like above ? (In a class that is not in the Console Project .
即使在类库或任何实用程序项目中,您仍然可以使用常规的System.Console
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.