如何建立收据号码 [英] how to build a receipt number

查看:81
本文介绍了如何建立收据号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我需要建立一个收据号,该收据的值是这个

RecieptCode LastRecieptNumber RecieptDisplayDigits
Rcp2008- 248 8


现在主要问题在receipdisplayDigits

我在python中知道如果我写z * 8将会是zzzzzzzz
我想在C#中使用相同的功能,但是如果我这样做了,我将无法添加最后一个接收号码/
>
这怎么办?
我有另一种方法,但可以肯定我的方法会更好.我的方法是将lastreceiptnumber
加10 ^(receipt display digt),然后删除1和编写如下所示的收据代码

上面的示例
10 ^ 8 = 100000000
100000000 + 249(因为它应该是新的收据)= 100000249
将其转换为字符串并删除1 = 00000249
然后我添加收据代码

有没有更好的方法考虑性能

最佳问候

Hello there i need to build a receipt number the values that am receiveing is this

RecieptCode LastRecieptNumber RecieptDisplayDigits
Rcp2008- 248 8


now the main prob is in receipdisplayDigits

i know in python if i write z*8 it will be zzzzzzzz
i want the same thing in C# but if i did it i will not be able to add the last reciept number/

how could this be done?
i have another method but am sure there would be a better one my method is to add the lastreceiptnumber
with 10^(receipt display digt) then i remove the 1 and write the receipt code it will look like this

the example above
10^8 = 100000000
100000000 + 249 (since it should be new receipt) = 100000249
Convert it to string and remove the 1 = 00000249
Then i add the receipt code

Is there better way taking into concideration the performance

Best Regards

推荐答案

我真的很喜欢逻辑您习惯使用8位数字的值,很高兴看到人们沿着这些思路思考,而不是期望通过简单的开箱即用"代码行完成事情(因此从不真正学习如何

但是在这种情况下,单线是可行的方法,因此希望对您有所帮助...

I really like the logic you have used in getting a value with 8 digits, it''s great to see people thinking along those lines rather than expecting things to be done with a simple ''out the box'' line of code (and thus never really learning how things are actually acheived).

But in instances like this one-liners are the way to go, so hope this helps...

int newNumber = lastReceiptNumber + 1;<br />string displayNumber = newNumber.ToString("D" + receiptDisplayDigits);






这篇关于如何建立收据号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆