可以输出从类库C#中的安慰? [英] Possible to output to console from within a class library C#?

查看:153
本文介绍了可以输出从类库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?

我知道在网络其可能获得的HttpContext,并做了的Response.Write。

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

推荐答案

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

你有没有想过使用日志库,如<一的HREF =http://logging.apache.org/log4net/index.html> log4net的呢?

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

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

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