Possible to output to console from within a class library C#?

Sure it is, just use System.Console.Write...


It depends on what type of application is going to use your class library. If it is used in a console application, then the output will be printed to the console. If it is a WinForms, Windows Service or ASP.NET application the output will be ignored.


Yup, Console.WriteLine etc will work just fine in a class library... but there's no guarantee that anything is listening to the console. If you use it from a WinForms app or a web app, that output may well go absolutely nowhere...

Have you thought of using a logging library such as log4net instead?

Tags:

C#

Console