• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

C# Code

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:

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