c# - 如何在 Windows 窗体应用程序中以古吉拉特语 native 数字显示数字?

标签 c# .net winforms localization

我想使用 c#.net 开发 Gujarati Windows 窗体应用程序。 但是我有一个问题

1) 古吉拉特语中两个数的计算。我通过这段代码解决了

public static double ParseValue(string value)
{
    return double.Parse(string.Join("",
        value.Select(c => "+-.".Contains(c)
           ? "" + c: "" + char.GetNumericValue(c)).ToArray()),
        NumberFormatInfo.InvariantInfo);
}

但此代码为我提供了 Eng 数值。

但是当计算两个 Guajarati 否时,我得到英文输出。像这样:

 Label1.Text = (ParseValue(TextBox1.Text) + ParseValue(TextBox2.Text)).ToString();

//Output is Like this
// ૩ + ૬ = 9

那么我怎样才能得到古吉拉特语数字的输出

2) Microsoft Access 中古吉拉特语值的数据类型是什么? 对于数字、日期时间等。

最佳答案

您可以使用 NumberFormatCultureInfo 属性来查找有关文化数字格式的信息,包括:

然后您可以使用此信息将您的号码转换为原始格式。

例如:

public string GetNativeRepresentation(double value)
{
    var format = CultureInfo.GetCultureInfo("gu-IN").NumberFormat;
    return String.Join("", value.ToString(CultureInfo.InvariantCulture)
                 .Select(x =>
                 {
                     if ("1234567890".Contains(x.ToString()))
                         return format.NativeDigits[x - '0'];
                     else if (x == '-')
                         return format.NegativeSign;
                     else if (x == '.')
                         return format.NumberDecimalSeparator;
                     else
                         return x.ToString();
                 }));
}

例如:

MessageBox.Show(GetNativeRepresentation(-1234567890.123));

显示:

-૧૨૩૪૫૬૭૮૯૦.૧૨૩

最好将每个类型独立于文化存储,例如,使用标准语言类型,如intdoubleDateTime,然后在使用 .Net Framework 本地化机制的应用程序,显示值的本地化版本。

关于c# - 如何在 Windows 窗体应用程序中以古吉拉特语 native 数字显示数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35099284/

相关文章:

c# - 将mysql数据库中的数据显示到列表框中(从组合框中选择的数据)c#

c# - 依赖属性如何工作?

c# - .net 本地程序集加载因 CAS 策略失败

c# - 类似utorrent的TreeView控件

c# - Entity Framework Code First 复合键上的一对一关系

c# - 需要引用类 CTOR 的对象(在构建对象之前)

c# - 嵌套多个 Task.WhenAll 和将所有任务扁平化为一个 Task.WhenAll 之间有区别吗?

C# 将焦点属性应用于 FlowLayoutPanel,如按钮行为

c# - 你如何制作一个包含多个 "Pages"的程序?

c# - Winform 闪烁问题