简体   繁体   中英

Add number to the ending of a numerical date value in C#

I'm trying to store an ID with the Date (month/day/year) in the same integer value in C#.

This way I can check whether a specific Id was already voted on in a particular day and prevent double voting in the same day. I store the votes in a static variable.

I convert the date to long using this code:

long.Parse(DateTime.Now.ToString("yyyyMMdd"));

So for today (2/9/2015) I get: 20150209

Now my IDs are integers. I want to append those to the converted date number.

So if for example the ID is 138, I want to add 138 to the end of the number, so the end result would be: 20150209138 .

How can I append the id to the converted numerical date like I've explained above?

long.Parse(DateTime.Now.ToString("yyyyMMdd")+ID.ToString());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM