Метод DateTime.ToLongDateString () в C #
Опубликовано: 6 Марта, 2022
Этот метод используется для преобразования значения текущего объекта DateTime в эквивалентное ему длинное строковое представление даты.
Syntax: public string ToLongDateString ();
Return Value: This method returns a string that contains the long date string representation of the current DateTime object.
Ниже приведены программы, иллюстрирующие использование метода DateTime.ToLongDateString () :
Пример 1:
Example 2:
// C# program to demonstrate the // DateTime.ToLongDateString() // Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // creating object of DateTime DateTime date = DateTime.Now; // Converting the value of the // current DateTime object to // its equivalent long date // string representation. // using ToLongDateString() method; string value = date.ToLongDateString(); // Display the date Console.WriteLine( "String representation " + "of date is {0}" , value); } } |
Output:
String representation of date is Monday, 11 February 2019
Ссылка:
- https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tolongdatestring?view=netframework-4.7.2