问题描述
有没有办法写入控制台/命令提示符/powershell(如 Console.WriteLine()
)或 UWP 应用程序中的任何类似内容?
Is there a way to write to console / command prompt / powershell (like Console.WriteLine()
) or anything similar in UWP apps?
如果控制台不可用,是否有合适的替代方法可以代替向屏幕写入大量文本?
If console is unavailable is there a proper alternative that I can use instead to write to the screen large amounts of text?
我当然可以制作 XAML 控件并输出给它,但与简单的 Console.WriteLine()
相比,它似乎并不方便.
I, of course, can make a XAML control and output to it, but it doesn't seem to be convenient in comparison to simple Console.WriteLine()
.
关于 WPF 控制台的讨论也非常古老,但似乎没有任何效果(至少,我找不到 Project-Properties-Application tab-Output Type-Console Application
和 Trace.WriteLine("text")
代码> 不可用).
There is also very old discussion on WPF console, but nothing seems to work from there (at least, I couldn't find Project-Properties-Application tab-Output Type-Console Application
and Trace.WriteLine("text")
is unavailable).
推荐答案
您可以使用 System.Diagnostics 命名空间中的 Debug.WriteLine 方法
You can use Debug.WriteLine method from System.Diagnostics namespace
当您开始调试应用程序时,这些消息将显示在输出窗口中(标准 VS 快捷键是 Ctrl+Alt+O,ReSharper 快捷键是 Ctrl+W, O)
When you start debugging your application those messages will be displayed in the Output Window (Standard VS shortcut is Ctrl+Alt+O, ReSharper shortcut is Ctrl+W, O)
这篇关于如何在 Windows 10 上的 UWP 中输出到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!