C# Code

  • Thread starter Thread starter rawger
  • Start date Start date
Joined
12/16/07
Messages
29
Points
11
I am trying to write a function in C# that generates a Unique User ID which should contain 7 digits.
The <Year><Month><Date><Hour><Hex Month><Hex Second><Ticker>


The purpose of this id would be that whenever a user submits a request , and ID would be assigned to him based on the above factors. For example if a user submits a request on Feb2 2008 then his id would be

080202...etc and so on


Has anybody got any suggestions on how to do it ?:-k

Thanks
 
You probably want to use the String.Format function to do the actual string concatenation & formatting (C# equivalent of sprintf, it seems). Your task is easy; the kind of thing that would come right after the Hello World program, so it's hard to know what you're looking for.
 
As doug rightly noted, you would probably need to use the String.Format method:

Code:
int ticker = 12;
string uniqueUserId = String.Format("{0:yyMMddHHmmss}{1}", DateTime.Now, ticker);
 
Back
Top Bottom