Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI am a new learner of C#.. I wanna do some project. in my project io have to generate email id optiions for the user from the first and last name i got from the user... ie: "Firstlast@x.com, lastfirst@x.com, firstfirst@x.com"... Please suggest some methods for me...
Posted

To get email id that does not exist, you should have all the already existing ids in a database.

Then you look for the different combination firstlast, lastfirst, firstfirst, ...
And each time you find a matching id in your database, you create a counter a try one more time with this counter value (ex. firstlast1, then firstlast2, ...)

Or do avoid a lot of requests to the database, if you know SQL syntax, you can do a search like:
SQL
SELECT knownid FROM KnownIDTable WHERE knownid LIKE 'firstlast%'

and then analyze the rows to get the unique value for your counter.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Dec-12 18:06pm    
5.--SA
you can concatenate first name and last name. but that will not always generate an unique mail id.

my suggestion is if you are building an application with a login , the login name should be unique value. you can get a combination of login name + first name+ last name
 
Share this answer
 
Comments
Pascal-78 10-Dec-12 10:51am    
Adding text to an unique id does not keep it unique.
A + BC + D = AB + C + D = ABCD
A & AB are different strings but with added characters the result strings are identical.
Sergey Alexandrovich Kryukov 10-Dec-12 18:05pm    
Good point. Another 5. :-)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900