SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Generate username

    Hi I am writing some logic that take first name from text file and Generate Employee ID for that Employee format First name Jack the id will be jak, put if I have to user with the same Employee with the same name or same user the Id format will be like this jak01


    Code Csharp:
                    List<string> empIDList = new List<string>();
                    for (int i = 0; i < emp.Length; i++)
                    {
                        for (int j = i + 1; j < emp.Length; j++)
                        {
                            if (emp[i].FirstName != emp[j].FirstName)
                            {
                                empIDList.Add(emp[i].FirstName.Substring(0, 3));
                                break;
                            }
                            else if (emp[i].FirstName == emp[j].FirstName)
                            {      numSufix++;
                                empIDList.Add(emp[i].FirstName.Substring(0, 3) + numSufix.ToString());
                                break;
                            }
     
     
                        }
                    }

  2. #2
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    656
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Was their a question here? Or, just to show how to do something?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •