可以从类库C#中输出到控制台? [英] Possible to output to console from within a class library C#?

查看:1414
本文介绍了可以从类库C#中输出到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从类库中输出值到控制台?

Is it possible to output values to the console from within a class library?

例如

 Console App -> calls method in -> assembly > function

是否可以在程序集的函数中编写一个console.out方法?

Is it possible to write a console.out method in the function of the assembly?

我知道在web它可能得到httpcontext,并做一个response.write。

I know in web its possible to get the httpcontext, and do a response.write.

推荐答案

Yup, Console.WriteLine 类库...但不能保证任何东西监听到控制台。如果你从WinForms应用程序或Web应用程序中使用它,该输出可能会绝对没有地方...

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...

您曾想过使用日志库,如 log4net

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

这篇关于可以从类库C#中输出到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆