100分请教java.text.DecimalFormat和c#里的那个class相对应

ken1024 2004-07-13 01:59:26
从java转换成c#的时候报如下错:

//UPGRADE_ISSUE: Class“java.text.DecimalFormat” 未转换。. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javatextDecimalFormat"'

DecimalFormat tDecimalFormat = new DecimalFormat("#############.#####");
System.String tStr = tDecimalFormat.FormatDouble(aValue);

提示说该用 String.Format 和包含在 System.Globalization 命名空间的类中的可自定义的格式模式。
可是上面的两行代码具体该怎么写?请达人解答!
一旦解决,立即结贴!
在线等待~~~谢谢各位!
...全文
170 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ken1024 2004-07-13
  • 打赏
  • 举报
回复
谢谢阿球兄,呵呵
253一下~
meixiaofeng 2004-07-13
  • 打赏
  • 举报
回复
支持你一下
「已注销」 2004-07-13
  • 打赏
  • 举报
回复
现在明白了吗?
「已注销」 2004-07-13
  • 打赏
  • 举报
回复
Double myDouble = 1234567890;
String myString = myDouble.ToString( "(###) ### - ####" );
// The value of myString is "(123) 456 – 7890".

ms-help://MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconcustomnumericformatstrings.htm
ken1024 2004-07-13
  • 打赏
  • 举报
回复
呵呵,给了我这么长,我想问一下,就是下面这两行代码如何转换:?
DecimalFormat tDecimalFormat = new DecimalFormat("#############.#####");
System.String tStr = tDecimalFormat.FormatDouble(aValue);

就是让指定的 tStr按照#############.#####的格式输出
谢谢~!
ken1024 2004-07-13
  • 打赏
  • 举报
回复
upto(阿球|Smart Client) ,谢谢,我用的是c#,那么using Microsoft.VisualBasic;会不会有问题?你有qq好吗?我请教你一下:我的8655813
谢谢!
「已注销」 2004-07-13
  • 打赏
  • 举报
回复
Detail....

ms-help://MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemDecimalClassToStringTopic.htm
「已注销」 2004-07-13
  • 打赏
  • 举报
回复
// Example for the Decimal.ToString( ) methods.
using System;
using System.Globalization;
using Microsoft.VisualBasic;

class DecimalToStringDemo
{
static void Main( )
{
decimal nineBillPlus = 9876543210.9876543210M;

Console.WriteLine( "This example of\n" +
" Decimal.ToString( ), \n" +
" Decimal.ToString( String ),\n" +
" Decimal.ToString( IFormatProvider ), and \n" +
" Decimal.ToString( String, IFormatProvider )\n" +
"generates the following output when run in the " +
"[{0}] culture.\nDecimal numbers are formatted " +
"with various combinations \nof format strings " +
"and IFormatProvider.",
CultureInfo.CurrentCulture.Name );

// Format the number without and with format strings.
Console.WriteLine( "\nIFormatProvider is not " +
"used; the default culture is [{0}]:",
CultureInfo.CurrentCulture.Name );
Console.WriteLine( " {0,-30}{1}", "No format string:",
nineBillPlus.ToString( ) );
Console.WriteLine( " {0,-30}{1}", "'N' format string:",
nineBillPlus.ToString( "N" ) );
Console.WriteLine( " {0,-30}{1}", "'N5' format string:",
nineBillPlus.ToString( "N5" ) );

// Create a CultureInfo object for another culture. Use
// [Dutch - The Netherlands] unless the current culture
// is Dutch language. In that case use [English - U.S.].
string cultureName =
CultureInfo.CurrentCulture.Name.Substring( 0, 2 ) ==
"nl" ? "en-US" : "nl-NL";
CultureInfo culture = new CultureInfo( cultureName );

// Use the CultureInfo object for an IFormatProvider.
Console.WriteLine( "\nA CultureInfo object " +
"for [{0}] is used for the IFormatProvider: ",
cultureName );
Console.WriteLine( " {0,-30}{1}", "No format string:",
nineBillPlus.ToString( culture ) );
Console.WriteLine( " {0,-30}{1}", "'N5' format string:",
nineBillPlus.ToString( "N5", culture ) );

// Get the NumberFormatInfo object from CultureInfo, and
// then change the digit group size to 4 and the digit
// separator to '_'.
NumberFormatInfo numInfo = culture.NumberFormat;
numInfo.NumberGroupSizes = new int[ ] { 4 };
numInfo.NumberGroupSeparator = "_";

// Use a NumberFormatInfo object for IFormatProvider.
Console.WriteLine(
"\nA NumberFormatInfo object with digit group " +
"size = 4 and \ndigit separator " +
"= '_' is used for the IFormatProvider:" );
Console.WriteLine( " {0,-30}{1}", "'N5' format string:",
nineBillPlus.ToString( "N5", culture ) );
}
}

/*
This example of
Decimal.ToString( ),
Decimal.ToString( String ),
Decimal.ToString( IFormatProvider ), and
Decimal.ToString( String, IFormatProvider )
generates the following output when run in the [en-US] culture.
Decimal numbers are formatted with various combinations
of format strings and IFormatProvider.

IFormatProvider is not used; the default culture is [en-US]:
No format string: 9876543210.9876543210
'N' format string: 9,876,543,210.99
'N5' format string: 9,876,543,210.98765

A CultureInfo object for [nl-NL] is used for the IFormatProvider:
No format string: 9876543210,9876543210
'N5' format string: 9.876.543.210,98765

A NumberFormatInfo object with digit group size = 4 and
digit separator = '_' is used for the IFormatProvider:
'N5' format string: 98_7654_3210,98765
*/
qingchunjingwu 2004-07-13
  • 打赏
  • 举报
回复
答:Decimal 结构!

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧