I am trying to create a unique value using a day,month,hour,minute and seconds. if i create the unique value at "2022/10/10 15:00:00" and i use ToString(), the "00" are truncated to "0"
var today = DateTime.Now;
string key = string.Format("341{0}{1}{2}{3}{4}", today.Date.Day, today.ToString("MM"), today.Hour.ToString(), today.Minute.ToString(), today.Second.ToString());
>Solution :
It’s not 00 value. It’s DateTime struct with int properties.
Use interpolation and proper DateTime format:
string key = $"341{today:ddMMHHmmss}"