无法使用Environment.GetResourceString静态方法 [英] Unable to use Environment.GetResourceString static method

查看:226
本文介绍了无法使用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"的定义.

The error is: 'System.Environment' does not contain a definition for 'GetResourceString'.

编辑:OP表示他正在使用Compact Framework v3.5.

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!

推荐答案

Environment.GetResourceString似乎存在. environment.getresourcestring%28VS.80%29.aspx"rel =" noreferrer> MSDN ,仅在Compact Framework 2.0版中.如果相信这篇文章,那么它在标准框架中就永远不会存在.

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.

您想做什么?如果您要进行本地化,则可能需要ResourceManager.GetString.

What are you trying to do? If it's localization you're after, you may want ResourceManager.GetString.

System.Resources.ResourceManager myManager = new 
   System.Resources.ResourceManager("ResourceNamespace.myResources", 
   myAssembly);

// Retrieves String and Image resources.
string myString = myManager.GetString("StringResource");

这篇关于无法使用Environment.GetResourceString静态方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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