C# 小数转数值(?,?)
我有一个问题,我还没有找到解决方案,所以我请求你的帮助。 在我的数据库中,我有一些整数、小数和字符串,需要将它们转换为具有特定长度和精度的数字,以包含在平面文件中。
例如:
integer 123 to numeric(8,0) ==> 00000123
decimal 123,123 to numeric(8,8) ==> 0000012312300000
String "22" to numeric(8,0) ==> 00000022
不能输入逗号或点。 有没有简单的解决办法 我尝试了很多事情,但除了循环 foreach 之外,没有一个能给我结果。在我的平面文件中归档太脏了!
编辑:
平面文件根据起点和长度获取信息,因此我在文件中包含的每个数据都必须是一定的长度。 对于数字,
database Decimal Price = 123,456
File Numeric(8,6) Price = 00000123456000
我例如想知道如何解析基于 N(,) 的任何小数或整数数据
I have a problem, i didn't found yet the solution so i am asking your help.
In my database I have some int, decimal and string that needs to be convert in numeric with specific length and precision to include in a flat file.
ex:
integer 123 to numeric(8,0) ==> 00000123
decimal 123,123 to numeric(8,8) ==> 0000012312300000
String "22" to numeric(8,0) ==> 00000022
It can't put comma or dot. Is there an easy solution
I try a lot of things but none will give me my result except doing loops foreach Filed in my flat file too dirty!!
EDIT:
the flat file gets information based on there start point and the lenght so every data i includ in the file has to be a cetain lenght. And for the Numeric I have for exemple
database Decimal Price = 123,456
File Numeric(8,6) Price = 00000123456000
I wanted to know how could i parse any decimal or integer data based on N(,)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
调用它:
或更一般:
Try this:
To call it:
or more general:
查看
String.Format
:http://msdn .microsoft.com/en-us/library/dwhawy9k.aspx
Check out
String.Format
:http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx