Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Convert.ToDateTime Method in C#
The Convert.ToDateTime method converts a given value to a DateTime value.
The following is my string.
string myDateString; myDateString = "09/09/2018";
Now, let us convert it using the Convert.ToDateTime() method.
DateTime result; result = Convert.ToDateTime(myDateString);
Here is the complete example.
Example
using System;
public class Demo {
public static void Main() {
string myDateString;
DateTime result;
myDateString = "09/09/2018";
result = Convert.ToDateTime(myDateString);
Console.WriteLine("'{0}' converted to {1}", myDateString, result);
}
}
Output
'09/09/2018' converted to 9/9/2018 12:00:00 AM
Advertisements
