在不使用 Microsoft.Visualbasic.Compatibility.dll 的情况下,相当于 vb.net 中的 vb6.Format 函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14133762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
equivalent for vb6.Format function in vb.net without using Microsoft.Visualbasic.Compatibility.dll
提问by ashish_pal
Possible Duplicate:
Is there a way to programmatically convert VB6 Formatting strings to .NET Formatting strings?
during migration from vb6 to vb.net the Format$(1234567, "###,###,###,###") function is converted to vb6.Format(1234567,"###,###,###,###") function, which is defined in Microsoft.Visualbasic.Compatibility.dll.
在从 vb6 迁移到 vb.net 期间,Format$(1234567, "###,###,###,###") 函数被转换为 vb6.Format(1234567,"###,### ,###,###") 函数,在 Microsoft.Visualbasic.Compatibility.dll 中定义。
I dont want to use Microsoft.Visualbasic.Compatibility.dll. Is there any equivalent for this in .NET.
我不想使用 Microsoft.Visualbasic.Compatibility.dll。在 .NET 中是否有任何等价物。
Thanks in advance.
提前致谢。
采纳答案by Mark Hall
You can use the .ToString(string) method
您可以使用.ToString(string) 方法
Dim value As Integer = 1234567
value.ToString("###,###,###,###")
or the String.Format Methodwhich uses Composite Formatting
String.Format("{0:###,###,###,###}", 1234567)

