将控制台应用程序转换为.dll时如何获取字符串输出? [英] How to get string output when converting a console application into a .dll?

查看:74
本文介绍了将控制台应用程序转换为.dll时如何获取字符串输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想将控制台应用程序转换为.dll文件,并在加载dll时得到结果,我不知道是怎么做的convert.Below是源控制台代码:

I want to convert a console application to a .dll file,and get the result when load the dll,what I don't know is how to get the result in a dll file after converted.Below is the origin console code:

推荐答案

好吧,"Console.WriteLine"只要从控制台应用程序加载DLL,它仍然会在从DLL执行时写入控制台。

Well, the "Console.WriteLine" will still write to the console when it executed from a DLL, as long as the DLL is loaded from a Console application.

当你说你想要"得到结果"时,你到底什么意思?如果你想在调用Console.WriteLine时收回你写出的字符串,你可以改为调用StringBuilder的Append方法,然后在
结尾返回StringBuilder的ToString()作为返回值对于转换后从DLL中暴露的任何方法。

When you say that you want "to get the result", what exactly do you mean? If you want to receive back the strings that you are writing out when calling Console.WriteLine, you could instead call the Append method of a StringBuilder and then at the end return the ToString() of the StringBuilder as the return value for whatever method you are exposing from the DLL once it is converted.


这篇关于将控制台应用程序转换为.dll时如何获取字符串输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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