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

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

সিনট্যাক্স

public string ToShortDateString ();

উদাহরণ

using System; 
public class Demo { 
    public static void Main() { 
        DateTime d = new DateTime(2019, 08, 11, 9, 10, 45); 
        Console.WriteLine("Date = {0}", d); 
        string str = d.ToShortDateString(); 
        Console.WriteLine("Short date string representation = {0}", str); 
    } 
}

আউটপুট

Date = 8/11/2019 9:10:45 AM Short date string representation = 8/11/2019

আরেকটি উদাহরণ (CultureInfo সহ)

using System; 
using System.Globalization; 
public class Demo { 
    public static void Main() { 
        DateTime d = DateTime.Now; 
        Console.WriteLine("Date = {0}", d); 
        Console.WriteLine("Current culture = " + CultureInfo.CurrentCulture.Name); 
        var pattern = CultureInfo.CurrentCulture.DateTimeFormat; 
        string str = d.ToShortDateString(); 
        Console.WriteLine("Short date string = {0}", pattern.ShortDatePattern); 
        Console.WriteLine("Short date string representation = {0}", str); 
    } 
}

আউটপুট

Date = 10/16/2019 8:56:40 AM Current culture = en-US Short date string = M/d/yyyy Short date string representation = 10/16/2019
  1. C#-এ DateTime.ToBinary() মেথড: DateTimeকে ৬৪-বিট বাইনারি-এ সিরিয়ালাইজ

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

  3. C#-এ DateTime.AddYears() পদ্ধতি

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