[英]how to generate a HOST NAME in asp.net?
I want to automatically generate a host name whenever user log in into the web.When they click the button log in, the system will automatically create a host name to them and the data automatically save in excel for record. 我想在用户登录网络时自动生成一个主机名。当用户单击登录按钮时,系统会自动为他们创建一个主机名,数据自动保存在excel中进行记录。 But, the problem is, I want to create a host name including company name eg;
但是,问题是,我想创建一个包含公司名称的主机名,例如; PEN + department name eg;
PEN +部门名称,例如; IT + any 4 of random number.
IT +任意4个随机数。 I'am still new in this asp.net and csharp language.
我仍然是这种asp.net和csharp语言的新手。 Please help me.Please teach me.
请帮助我。请教我。
This would seem to be what you're asking for 这似乎是您要的
Random rand = new Random();
string hostName = companyName + departmentName + rand.Next(1000,9999).ToString();
It's better if Random rand = new Random();
最好是
Random rand = new Random();
is called once and not everytime you create a new hostName, because you want to avoid any possibility that 2 Random objects would have the same seed. 一次调用一次,而不是每次创建新的hostName一次,因为您要避免2个Random对象具有相同种子的可能性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.