2
Answers

how to add current timestamp while generating Id

Photo of Sowmya Sirsi

Sowmya Sirsi

3y
773
1

private void ProcessRequestForCommissionProvisioning(Model.ClassObject.Request commissionreq)

{

//code goes here

accReq.ConsumerID = commissionreq.ConsumerID;

accReq.transactionID = "EPDCM_" + commissionreq.ID;

accReq.OperationType = commissionreq.OperationType;

}

Note: Here in this line "accReq.transactionID = "EPDCM_" + commissionreq.ID;"  we are generating new ID 

         How to make sure I add Current timestamp along with this line "accReq.transactionID = "EPDCM_" + commissionreq.ID;"

Please assist me

Answers (2)

2
Photo of Sachin Singh
NA 55.8k 88.5k 3y
This way?
  1. accReq.transactionID = "EPDCM_" + commissionreq.ID+DateTime.Now.ToString("hh:mm:ss");  
 
Accepted
0
Photo of Salman Beg
154 12.1k 623.2k 3y
For the current timestamp you need to use DateTime.Now and concatenate that value to accReq.transactionID. See this below link for DateTime.Now, https://www.codegrepper.com/code-examples/csharp/c%23+get+current+timestamp https://stackoverflow.com/questions/21219797/how-to-get-correct-timestamp-in-c-sharp/21219819