为什么带有 System.Console.WriteLine 的单行应用程序会给我一个语法错误?
在多次令人沮丧的经历之后,我决定再次尝试使用 Windows 开发人员预览版构建 Windows Metro 风格的应用程序。
所以我启动了 Visual Studio,然后砰的一声!当我尝试输入此代码时,
System.Console.WriteLine("");
它在“控制台”下显示红色波浪线。
所以我尝试了其他方法:
string text = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\WriteText.txt");
但也失败了!文件下呈红色波浪状。
为什么会弹出这个错误?所有这些代码应该可以正常工作!或者我犯了一个基本错误?
I decided to have a go at building Windows Metro style apps with the Windows Developer Preview again, after multiple frustrating experiences.
So I fire up Visual Studio and BAM! Right as I try to type in this code
System.Console.WriteLine("");
it gives me the red squiggly under "Console".
So I try something else:
string text = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\WriteText.txt");
and THAT fails as well! Red squiggly under File.
Why is this error popping up? All this code should work fine! Or am I making a basic mistake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为 Metro 应用程序使用 .Net Framework API 的子集。在此版本中
System.Console
和System.IO.File
不存在。来自 MSDN,“将
System.IO.File.ReadAllText
方法替换为使用异步 I/O 成员的方法;例如:”Because Metro applications use a subset of the .Net Framework API. In this version
System.Console
andSystem.IO.File
do not exist.From MSDN, "Replace
System.IO.File.ReadAllText
method with a method that uses the asynchronous I/O members; for example:"Windows 8 Metro 应用程序没有控制台(因为图形环境中的控制台没有意义),但您可以通过第三方库(例如 Metro 应用程序的控制台类
Windows 8 Metro Apps don't have a console (as the console in a graphical environment doesn't make sense), but you can get some of the functionality of the console with third party libraries like Console Class for Metro Apps