কম্পিউটার টিউটোরিয়াল

C#-এ DateTime.ToString() মেথড

সিনট্যাক্স

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
  1. C#-এ DateTime.CompareTo() মেথড: তারিখ তুলনা করার পদ্ধতি

  2. C#-এ DateTime.ToFileTime() মেথড: DateTime থেকে উইন্ডোজ ফাইল টাইম

  3. C#-এ DateTime.ToBinary() মেথড: DateTimeকে ৬৪-বিট বাইনারি-এ সিরিয়ালাইজ

  4. C#-এ DateTime.Subtract() মেথড: তারিখ বা টাইমস্প্যান বিয়োগ করা