সিনট্যাক্স
ToString(String, IFormatProvider) ToString() ToString(IFormatProvider) ToString(String)
উদাহরণ
DateTime.ToString() মেথড বাস্তবায়ন:
using System;
public class Demo {
public static void Main() {
DateTime d = new DateTime(2019, 11, 11, 7, 11, 25);
Console.WriteLine("Date = {0}", d);
string str = d.ToString();
Console.WriteLine("String representation = {0}", str);
}
}
আউটপুট
Date = 11/11/2019 7:11:25 AM String representation = 11/11/2019 7:11:25 AM
DateTime.ToString(String) মেথডের উদাহরণ
using System;
public class Demo {
public static void Main() {
DateTime d = new DateTime(2019, 11, 11, 7, 11, 25);
Console.WriteLine("Date = {0}", d);
string str = d.ToString("f");
Console.WriteLine("String representation = {0}", str);
}
}
আউটপুট
Date = 11/11/2019 7:11:25 AM String representation = Monday, November 11, 2019 7:11 AM