Search code examples
c#uniqueuserid

How to generate customized user id?


I'm working on a web application that is required to enable a multitude of users of various designations to log into a system. But unlike conventional method of generating user ids, I want to use certain parameters.

Eg: TECH12nameIND01

Here the example I've mentioned above contains

  • designation
  • year of join
  • name of the emp
  • location
  • auto increment number

The user id should appear in my registration page at the end of registering.

I seek the C# code for this particular issue.


Solution

  • Have you tried string.format?

    string pattern ="{0}{1}{2}{3}{4}";
    string username = string.Format(pattern,"Tech",12,"name","IND","01");