You are looking for the DateTime.Parse()
method (MSDN Article)
So you can do:
var dateTime = DateTime.Parse("01/01/2001");
Which will give you a DateTime
typed object.
If you need to specify which date format you want to use, you would use DateTime.ParseExact
(MSDN Article)
Which you would use in a situation like this (Where you are using a British style date format):
string[] formats= { "dd/MM/yyyy" }
var dateTime = DateTime.ParseExact("01/01/2001", formats, new CultureInfo("en-US"), DateTimeStyles.None);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…