Consider this:
var date = "11252017";
var arrDate = date.ToArray();
var strDate = arrDate[0] + arrDate[1] + "https://stackoverflow.com/" +
arrDate[2] + arrDate[3] + "https://stackoverflow.com/" +
arrDate[4] + arrDate[5] + arrDate[6] + arrDate[7]; // 98/25/2017
Notice that:
'1' + '1' = 98
* ⇒char
+char
=int
98 + "https://stackoverflow.com/" = "98/"
⇒int
+string
=string
"98/" + '2' = "98/2"
⇒string
+char
=string
The fix:
var dt = DateTime.Parse("" +
arrDate[0] + arrDate[1] + "https://stackoverflow.com/" +
arrDate[2] + arrDate[3] + "https://stackoverflow.com/" +
arrDate[4] + arrDate[5] + arrDate[6] + arrDate[7]);
*ASCII representation:
'1'
in decimal is49
3
solved How to convert char array into string for DateTime.Parse? [closed]