c# - How to generate a reference number by using customer name and year? -


i want generate unique number based on customer name , date of birth.

if customer name chandra shekar , date of birth 28/12/1990.

i want xxxx-1990

xxxx should number should generate based on customer name.

how can generate number string value?

thank you.

this tricky if need able guarantee uniqueness immediately. scheme tries convert string "small" number (one smaller in terms of information original string) suffer possible collisions.

so depends on requirements. if need able reliably generate id later on give name , number purely algorithmically, you've got problem.

on other hand, if can store "name, date of birth, generated id" in table somewhere, start using hash of form (i wouldn't suggest using gethashcode there's no guarantee stay stable on time, common cryptographic hash should fine) , results in table. use part uniqueness, too. example, if hash "fred blogs" gave 1234, , did hash "jim smith", might end with:

fred blogs => 1234-0-1990 jim smith =>  1234-1-1990 

but again, if you're in situation consider generating globally unique id start with. it's working out exact requirements before try solve them. say, should abandon idea of "a number unique" - that's doomed due pigeonhole principle.

as habib mentions, need consider possibility of multiple customers same name , birth date.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -