How to generate unique number of 12 digits?

前端 未结 4 1495
误落风尘
误落风尘 2021-01-03 17:08

I\'m working on an app that sends raw data to zebra printer and print out barcodes. And since every item has its own unique barcode, I need to define a variable that automat

4条回答
  •  庸人自扰
    2021-01-03 17:40

    You can simply use:

    var temp = Guid.NewGuid().ToString().Replace("-", string.Empty);
    var barcode = Regex.Replace(temp,"[a-zA-Z]", string.Empty).Substring(0, 12);
    

提交回复
热议问题