convert string to date in csharp

Code Example - convert string to date in csharp

                
                        DateTime convertedDate = DateTime.Parse(Date.ToString("yyyy-MM-dd"));
                    
                
 

csharp string to datetime

                        
                                string iDate = "05/05/2005";
DateTime oDate = Convert.ToDateTime(iDate);
MessageBox.Show(oDate.Day + " " + oDate.Month + "  " + oDate.Year );
                            
                        
 

string to datetime csharp

                        
                                DateTime.TryParse(stringDate, out DateTime date);
//date variable type is DateTime