无法使用Environment.GetResourceString静态方法
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var x = Environment.GetResourceString("test"); //compile-time error
}
}
}
错误是:“System.Environment”不包含“GetResourceString”的定义。
编辑:OP 表示他正在使用 Compact Framework v3.5。
我看不懂图片,我的代码有什么问题吗?谢谢!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var x = Environment.GetResourceString("test"); //compile-time error
}
}
}
The error is: 'System.Environment' does not contain a definition for 'GetResourceString'.
EDIT: OP has stated that he's using the Compact Framework, v3.5.
I dont get the picture, what's wrong with my code? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Environment.GetResourceString 不是公开的,
请参阅 Michael Petrotta 的回答以了解如何访问资源,或者查看此处的示例 http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.aspx
Environment.GetResourceString is not public
See Michael Petrottas answer for how to access resources or have a look at the samples here http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.aspx
根据 MSDN,仅适用于 Compact Framework 2.0 版本。如果这篇文章可信,那么它在标准框架中从未存在过。
你想做什么?如果您需要本地化,您可能需要
ResourceManager.GetString
。Environment.GetResourceString
appears to be present, according to MSDN, only in version 2.0 of the Compact Framework. If the article is to be believed, it's never existed in the standard framework.What are you trying to do? If it's localization you're after, you may want
ResourceManager.GetString
.您无法访问Environment.GetResourceString,但如果您需要访问mscorlib 的内部错误消息,请定义您自己的实现。
PS 这里列出了所有消息及其 ID。
You cannot access
Environment.GetResourceString
, but if you need access to mscorlib's internal error message, define your own implementation of that.P. S. Here a list of all messages with their ID.