相关疑难解决方法(0)

CultureInfo.CurrentCulture从哪里读取文化

我想知道从哪里System.Globalization.CultureInfo.CurrentCulture读取其值的设置或位置 .

我正在使用Windows 7笔记本电脑,并已将我的系统的区域和日期时间设置更改为美国.

我在下面的web.config设置下使用了我的代码

<globalization culture="en-US" />
Run Code Online (Sandbox Code Playgroud)

谢谢

asp.net globalization

7
推荐指数
2
解决办法
2万
查看次数

如何在 C# 中覆盖枚举上的 ToString()?

我在项目中的所有类和命名空间之外声明了以下枚举:

public enum ServerType { Database, Web } // there are more but omitted for brevity

我想用以下内容覆盖该ToString()方法:

public override string ToString(ServerType ServerType)
{
    switch (ServerType)
    {
        case ServerType.Database:
            return "Database server";
        case ServerType.Web:
            return "Web server";
    }
    // other ones, just use the base method
    return ServerType.ToString();
}
Run Code Online (Sandbox Code Playgroud)

但是我收到一个错误 no suitable method found to override

使用我自己的方法转换为字符串时是否可以覆盖枚举?

c# enums overriding c#-5.0

5
推荐指数
1
解决办法
6985
查看次数

标签 统计

asp.net ×1

c# ×1

c#-5.0 ×1

enums ×1

globalization ×1

overriding ×1