自动生成的唯一ID的代码 [英] code for autogenerated unique id

查看:67
本文介绍了自动生成的唯一ID的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要8个字母的自动生成的唯一ID的代码,前4个将是fistname或lastname,接下来的4个将是数字.当他输入个人信息的详细信息并单击提交"按钮时,将显示唯一的ID,并将其发送到他的邮件ID.我想要此自动生成的代码

i want code for autogenerated unique id with 8 letters, first 4 will be fistname or lastname and next four will be numbers. when he enter the details of personal information and click on the submit button the unique id will be displayedand it will be sent to his mail id.i want code behind this auto generated

推荐答案

亲爱的朋友,

试试这个:-

1).首先获取ID为
Dear Friend,

Try this:-

1). First take a string for ID
string ID="";


的字符串
2).将名字或姓氏添加到字符串ID



2). Add the First Or Last Name to the string ID

ID=[FirstName]/[LastName];



3).现在通过此
生成4位数字的随机数



3). Now generate the random number of 4 digits through this

Random rnd = new Random();
long number = Convert.ToInt64(rnd.Next(1000,10000));



4).连接两个字符串,即字符串 ID 和Long rnd 以生成所需的ID.



4). Concatenate the two i.e., the string ID and the Long rnd to generate the required ID.

ID=ID + Convert.ToString(rnd)


如果您有帮助,请不要忘记将其标记为答案.

谢谢


Please don''t forget to mark this as your answer if it helps you out.

Thanks


尝试一下
Guid g = Guid.NewGuid();

        string random = g.ToString();

        Response.Write(random.Substring(0, 4));


这篇关于自动生成的唯一ID的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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