C# DateTime的11種構造函數

来源:https://www.cnblogs.com/HapetyPing/archive/2018/09/30/9728011.html
-Advertisement-
Play Games

別的也不多說沒直接貼代碼 ...


別的也不多說沒直接貼代碼

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

namespace Time20180929_DateTime
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             * 1.DateTime(Int64):將 DateTime 結構的新實例初始化為指定的刻度數。
             * 2.DateTime(Int64, DateTimeKind):將 DateTime 結構的新實例初始化為指定的計時周期數以及協調世界時 (UTC) 或本地時間。
             * 3.DateTime(Int32, Int32, Int32):將 DateTime 結構的新實例初始化為指定的年、月和日。
             * 4.DateTime(Int32, Int32, Int32, Calendar):將 DateTime 結構的新實例初始化為指定日曆的指定年、月和日。
             * 5.DateTime(Int32, Int32, Int32, Int32, Int32, Int32):將 DateTime 結構的新實例初始化為指定的年、月、日、小時、分鐘和秒。
             * 6.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)    :將 DateTime 結構的新實例初始化為指定年、月、日、小時、分鐘、秒和協調世界時 (UTC) 或本地時間。
             * 7.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Calendar):將 DateTime 結構的新實例初始化為指定日曆的年、月、日、小時、分鐘和秒。
             * 8.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32):將 DateTime 結構的新實例初始化為指定的年、月、日、小時、分鐘、秒和毫秒。
             * 9.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind):將 DateTime 結構的新實例初始化為指定年、月、日、小時、分鐘、秒、毫秒和協調世界時 (UTC) 或本地時間。
             * 10.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar):將 DateTime 結構的新實例初始化為指定日曆的指定年、月、日、小時、分鐘、秒和毫秒。
             * 11.DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, DateTimeKind):將 DateTime 結構的新實例初始化為指定日曆的指定年、月、日、小時、分鐘、秒、毫秒和協調世界時 (UTC) 或本地時間。
             */



            /*
             * 1.public DateTime (long ticks):
             * 一個日期和時間,以西曆 0001 年 1 月 1 日 00:00:00.000 以來所經歷的以 100 納秒為間隔的間隔數來表示。
             * ticks 小於 MinValue 或大於 MaxValue。
             */
            //時間屬性MinValue和MaxValue
            long _minval = DateTime.MinValue.Ticks;
            long _maxval = DateTime.MaxValue.Ticks;
            DateTime _mintime = DateTime.MinValue;
            DateTime _maxtime = DateTime.MaxValue;
            string desc = "minval:{0}, _maxval:{1}, _mintime:{2}, _maxtime:{3}";

            string format = "{0}) The {1} date and time is {2:MM/dd/yy hh:mm:ss tt}";
            DateTime dt1 = new DateTime(DateTime.MinValue.Ticks);
            DateTime dt2 = new DateTime(DateTime.MaxValue.Ticks);

            //創建一個傳統時間為上午2018/9/29 10:39:50基於名稱指定的區域性"en-US"並基於布爾值(指定是否使用系統中用戶選定的區域性設文化ticks
            long ticks = new DateTime(2018, 9, 29, 10, 39, 50, new CultureInfo("en-US", false).Calendar).Ticks;
            DateTime dt3 = new DateTime(ticks);

            Console.WriteLine(desc, _minval, _maxval, _mintime, _maxtime);
            Console.WriteLine(format, 1, "minimum", dt1);
            Console.WriteLine(format, 2, "maxmum", dt2);
            Console.WriteLine(format, 3, "custom ", dt3);
            Console.WriteLine("\nThe custom date and time is created from {0:N0} ticks.", ticks);
            Console.WriteLine("\nThe custom date and time is created from {0} ticks.", ticks);

            /*
            minval:0, _maxval:3155378975999999999, _mintime:0001/1/1 0:00:00, _maxtime:9999/12/31 23:59:59
            1) The minimum date and time is 01/01/01 12:00:00 上午
            2) The maxmum date and time is 12/31/99 11:59:59 下午
            3) The custom  date and time is 09/29/18 10:39:50 上午

            The custom date and time is created from 636,738,143,900,000,000 ticks.

            The custom date and time is created from 636738143900000000 ticks.
             */

            /*
             * 2.public DateTime (long ticks, DateTimeKind kind);
             * DateTime(Int64, DateTimeKind):將 DateTime 結構的新實例初始化為指定的計時周期數以及協調世界時 (UTC) 或本地時間。
             * kind:
             * Unspecified  0   表示的時間既未指定為本地時間,也未指定為協調通用時間 (UTC)。
             * Utc          1   表示的時間為 UTC。
             * Local        2   表示的時間為本地時間
             */
            long ticks2 = new DateTime(2018, 9, 29, 10, 39, 50, new CultureInfo("en-US", false).Calendar).Ticks;
            Console.WriteLine("2018-09-29 10:39:50");
            Console.WriteLine("Unspecified:{0}", new DateTime(ticks2, DateTimeKind.Unspecified));
            Console.WriteLine("Utc:{0}", new DateTime(ticks2, DateTimeKind.Utc));
            Console.WriteLine("Local:{0}", new DateTime(ticks2, DateTimeKind.Local));
            /*
             2018-09-29 10:39:50
            Unspecified:2018/9/29 10:39:50
            Utc:2018/9/29 10:39:50
            Local:2018/9/29 10:39:50
             */
            /*
             * 3.public DateTime (int year, int month, int day);
             * DateTime(Int32, Int32, Int32)
             * 將 DateTime 結構的新實例初始化為指定的年、月和日。
             * year:1-9999,month:0-12,day:1-moth中的天數
             */
            DateTime dt4 = new DateTime(2018, 9, 18);
            Console.WriteLine("dt4的值為{0}", dt4.ToString());
            /*
             dt4的值為2018/9/18 0:00:00
             */


            /*
             * 4.public DateTime (int year, int month, int day, System.Globalization.Calendar calendar);
             * DateTime(Int32, Int32, Int32, Calendar):將 DateTime 結構的新實例初始化為指定日曆的指定年、月和日。
             * year:1-9999,month:0-12,day:1-moth中的天數,Calendar用於解釋 year、month 和 day 的日曆。
             */
            /*
             下麵的示例調用DateTime(Int32, Int32, Int32, Calendar)構造函數兩次實例化兩個DateTime值。 第一次調用實例化DateTime通過使用值PersianCalendar對象。 由於波斯日曆不能指定為區域性的預設日曆,顯示日期與波斯歷需要單獨調用其PersianCalendar.GetMonth, PersianCalendar.GetDayOfMonth,和PersianCalendar.GetYear方法。 構造函數的第二個調用實例化DateTime通過使用值HijriCalendar對象。 該示例將當前區域性更改為阿拉伯語 (敘利亞) 和當前區域性的預設日曆更改為回歷。 因為回歷是當前區域性的預設日曆,Console.WriteLine方法使用它來設置日期格式。 還原先前的當前區域性 (這在此情況下是英語 (美國)) 時,Console.WriteLine方法使用當前區域性的預設西曆日曆來設置日期格式。
             */
           Console.WriteLine("Using the Persian Calendar:");
           PersianCalendar persian = new PersianCalendar();
           DateTime dt5 = new DateTime(2018,9,29, persian);
           Console.WriteLine(dt5.ToString());
           Console.WriteLine("{0}/{1}/{2}\n", persian.GetMonth(dt5),persian.GetDayOfMonth(dt5),persian.GetYear(dt5));

           Console.WriteLine("Using the Hijri Calendar:");
           CultureInfo dftCulture = Thread.CurrentThread.CurrentCulture;

           // Define Hijri calendar.
           HijriCalendar hijri = new HijriCalendar();
           // Make ar-SY the current culture and Hijri the current calendar.
           Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-SY");
           CultureInfo current = CultureInfo.CurrentCulture;
           current.DateTimeFormat.Calendar = hijri;
           string dFormat = current.DateTimeFormat.ShortDatePattern;
           // Ensure year is displayed as four digits.
           dFormat = Regex.Replace(dFormat, "/yy$", "/yyyy");
           current.DateTimeFormat.ShortDatePattern = dFormat;
           DateTime date2 = new DateTime(2018,9,29, hijri);
           Console.WriteLine("{0} culture using the {1} calendar: {2:d}", current,GetCalendarName(hijri), date2);

           // Restore previous culture.
           Thread.CurrentThread.CurrentCulture = dftCulture;
           Console.WriteLine("{0} culture using the {1} calendar: {2:d}",CultureInfo.CurrentCulture,GetCalendarName(CultureInfo.CurrentCulture.Calendar),date2);
           /*
            Using the Persian Calendar:
           2639/12/20 0:00:00
           9/29/2018

           Using the Hijri Calendar:
           ar-SY culture using the Hijri calendar: 29/09/2018
           zh-CN culture using the Gregorian calendar: 2580/3/16
            */

            /*
             * 5.public DateTime (int year, int month, int day, int hour, int minute, int second);
             * DateTime(Int32, Int32, Int32, Int32, Int32, Int32)
             * 將 DateTime 結構的新實例初始化為指定的年、月、日、小時、分鐘和秒。
             * year:1-9999,month:0-12,day:1-moth中的天數,hour:0-23,minuye:0-59,second:0-59
             */
            DateTime date1 = new DateTime(2018, 9, 29, 11, 20, 26);
            Console.WriteLine(date1.ToString());
            /*2018/9/29 11:20:26*/

            /*
             * 6.public DateTime (int year, int month, int day, int hour, int minute, int second, DateTimeKind kind);
             * DateTime(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)
             * 將 DateTime 結構的新實例初始化為指定年、月、日、小時、分鐘、秒和協調世界時 (UTC) 或本地時間。
             * year:1-9999,month:0-12,day:1-moth中的天數,hour:0-23,minuye:0-59,second:0-59
             *kind:
             *Unspecified  0   表示的時間既未指定為本地時間,也未指定為協調通用時間 (UTC)。
             *Utc          1   表示的時間為 UTC。
             *Local        2   表示的時間為本地時間
             */
            DateTime date9 = new DateTime(2010, 8, 18, 16, 32, 0, DateTimeKind.Local);
            Console.WriteLine("日期:{0}\nDateTimeKind:{1}", date9, date9.Kind);
            /*
             日期:2010/8/18 16:32:00
              DateTimeKind:Local
             */

            /*
             *7.public DateTime (int year, int month, int day, int hour, int minute, int second, System.Globalization.Calendar calendar);
             * DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Calendar)
             * 將 DateTime 結構的新實例初始化為指定日曆的年、月、日、小時、分鐘和秒。
             * year:1-9999,month:0-12,day:1-moth中的天數,hour:0-23,minuye:0-59,second:0-59,
             * calendar:用於解釋 year、month 和 day 的日曆。
             */

            /*
             *8.public DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond);
             * DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
             * 將 DateTime 結構的新實例初始化為指定的年、月、日、小時、分鐘、秒和毫秒。
             * year:1-9999,month:0-12,day:1-moth中的天數,hour:0-23,minuye:0-59,second:0-59,millisecond:0-999
             */

            DateTime date3 = new DateTime(2018, 9, 29, 13, 44, 30, 555);
            Console.WriteLine(date3.ToString("MM/dd/yyyy HH:mm:ss.fff tt"));
            /*09/29/2018 13:44:30.555 下午*/

            /*
             * 9.public DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, DateTimeKind kind);
             * DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, DateTimeKind)
             * 將 DateTime 結構的新實例初始化為指定年、月、日、小時、分鐘、秒、毫秒和協調世界時 (UTC) 或本地時間。   
             * year:1-9999,month:0-12,day:1-moth中的天數,hour:0-23,minuye:0-59,second:0-59,millisecond:0-999
             * kind:枚舉值之一,該值指示 year、month、day、hour、minute、second 和 millisecond 指定了本地時間、
             * 協調世界時 (UTC),還是兩者皆未指定。
             */
            DateTime date4 = new DateTime(2018, 9, 29, 13, 48, 30, 500, DateTimeKind.Local);
            Console.WriteLine("{0:M/dd/yyyy h:mm:ss.fff tt} {1}", date4, date4.Kind);
            /*
             * 9/29/2018 1:48:30.500 下午 Local
             */

            /*
             * 10.public DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, System.Globalization.Calendar calendar);
             * DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar)
             * 將 DateTime 結構的新實例初始化為指定日曆的指定年、月、日、小時、分鐘、秒和毫秒。
             * year:1-9999,month:0-12,day:1-moth中的天數,hour:0-23,minuye:0-59,second:0-59,millisecond:0-999
             * calendar:用於解釋 year、month 和 day 的日曆
             */

            /*
             下麵的示例調用DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar)構造函數兩次實例化兩個DateTime值。 第一次調用實例化DateTime通過使用值PersianCalendar對象。 由於波斯日曆不能指定為區域性的預設日曆,顯示日期與波斯歷需要單獨調用其PersianCalendar.GetMonth, PersianCalendar.GetDayOfMonth,和PersianCalendar.GetYear方法。 構造函數的第二個調用實例化DateTime通過使用值HijriCalendar對象。 該示例將當前區域性更改為阿拉伯語 (敘利亞) 和當前區域性的預設日曆更改為回歷。 因為回歷是當前區域性的預設日曆,Console.WriteLine方法使用它來設置日期格式。 還原先前的當前區域性 (這在此情況下是英語 (美國)) 時,Console.WriteLine方法使用當前區域性的預設西曆日曆來設置日期格式。
             */
            Console.WriteLine("Using the Persian Calendar:");
            PersianCalendar persian2 = new PersianCalendar();
            DateTime date5 = new DateTime(1397, 3, 29, 16, 32, 18, 500, persian2);
            Console.WriteLine(date5.ToString("M/dd/yyyy h:mm:ss.fff tt"));
            Console.WriteLine("{0}/{1}/{2} {3}{7}{4:D2}{7}{5:D2}.{6:G3}\n",
                                             persian2.GetMonth(date5),
                                             persian2.GetDayOfMonth(date5),
                                             persian2.GetYear(date5),
                                             persian2.GetHour(date5),
                                             persian2.GetMinute(date5),
                                             persian2.GetSecond(date5),
                                             persian2.GetMilliseconds(date5),
                                             DateTimeFormatInfo.CurrentInfo.TimeSeparator);

            Console.WriteLine("Using the Hijri Calendar:");
            // Get current culture so it can later be restored.
            CultureInfo dftCulture2 = Thread.CurrentThread.CurrentCulture;

            // Define strings for use in composite formatting.
            string dFormat2;
            string fmtString;
            // Define Hijri calendar.
            HijriCalendar hijri2 = new HijriCalendar();
            // Make ar-SY the current culture and Hijri the current calendar.
            Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-SY");
            CultureInfo current2 = CultureInfo.CurrentCulture;
            current2.DateTimeFormat.Calendar = hijri2;
            dFormat2 = current.DateTimeFormat.ShortDatePattern;
            // Ensure year is displayed as four digits.
            dFormat2 = Regex.Replace(dFormat2, "/yy$", "/yyyy") + " H:mm:ss.fff";
            fmtString = "{0} culture using the {1} calendar: {2:" + dFormat2 + "}";
            DateTime date6 = new DateTime(1431, 9, 9, 16, 32, 18, 500, hijri2);
            Console.WriteLine(fmtString, current2, GetCalendarName(hijri2), date6);

            // Restore previous culture.
            Thread.CurrentThread.CurrentCulture = dftCulture;
            dFormat2 = DateTimeFormatInfo.CurrentInfo.ShortDatePattern + " H:mm:ss.fff";
            fmtString = "{0} culture using the {1} calendar: {2:" + dFormat2 + "}";
            Console.WriteLine(fmtString,
                              CultureInfo.CurrentCulture,
                              GetCalendarName(CultureInfo.CurrentCulture.Calendar),
                              date6);

            /*
             Using the Persian Calendar:
             6/19/2018 4:32:18.500 下午
             3/29/1397 16:32:18.500

             Using the Hijri Calendar:
             ar-SY culture using the Hijri calendar: 09/09/1431 16:32:18.500
             zh-CN culture using the Gregorian calendar: 2010/8/18 16:32:18.500
             */

            /*
             * 11.public DateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, System.Globalization.Calendar calendar, DateTimeKind kind);
             * DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, DateTimeKind)
             * 將 DateTime 結構的新實例初始化為指定日曆的指定年、月、日、小時、分鐘、秒、毫秒和協調世界時 (UTC) 或本地時間。
             * year:1-9999,month:0-12,day:1-moth中的天數,hour:0-23,minuye:0-59,second:0-59,millisecond:0-999
             * calendar:用於解釋 year、month 和 day 的日曆
             * kind:枚舉值之一,該值指示 year、month、day、hour、minute、second 和 millisecond 指定了本地時間、
             * 協調世界時 (UTC),還是兩者皆未指定。
             */
            /*
            下麵的示例調用DateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Calendar, DateTimeKind)構造函數兩次實例化兩個DateTime值。 第一次調用實例化DateTime通過使用值PersianCalendar對象。 由於波斯日曆不能指定為區域性的預設日曆,顯示日期與波斯歷需要單獨調用其PersianCalendar.GetMonth, PersianCalendar.GetDayOfMonth,和PersianCalendar.GetYear方法。 構造函數的第二個調用實例化DateTime通過使用值HijriCalendar對象。 該示例將當前區域性更改為阿拉伯語 (敘利亞) 和當前區域性的預設日曆更改為回歷。 因為回歷是當前區域性的預設日曆,Console.WriteLine方法使用它來設置日期格式。 還原先前的當前區域性 (這在此情況下是英語 (美國)) 時,Console.WriteLine方法使用當前區域性的預設西曆日曆來設置日期格式。 
            */
            Console.WriteLine("Using the Persian Calendar:");
            PersianCalendar persian3 = new PersianCalendar();
            DateTime date7 = new DateTime(1397, 3, 29, 16, 32, 18, 500,
                                          persian3, DateTimeKind.Local);
            Console.WriteLine("{0:M/dd/yyyy h:mm:ss.fff tt} {1}", date7, date7.Kind);
            Console.WriteLine("{0}/{1}/{2} {3}{8}{4:D2}{8}{5:D2}.{6:G3} {7}\n",
                                             persian3.GetMonth(date7),
                                             persian3.GetDayOfMonth(date7),
                                             persian3.GetYear(date7),
                                             persian3.GetHour(date7),
                                             persian3.GetMinute(date7),
                                             persian3.GetSecond(date7),
                                             persian3.GetMilliseconds(date7),
                                             date7.Kind,
                                             DateTimeFormatInfo.CurrentInfo.TimeSeparator);

            Console.WriteLine("Using the Hijri Calendar:");
            // Get current culture so it can later be restored.
            CultureInfo dftCulture3 = Thread.CurrentThread.CurrentCulture;

            // Define strings for use in composite formatting.
            string dFormat3;
            string fmtString3;
            // Define Hijri calendar.
            HijriCalendar hijri3 = new HijriCalendar();
            // Make ar-SY the current culture and Hijri the current calendar.
            Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-SY");
            CultureInfo current3 = CultureInfo.CurrentCulture;
            current3.DateTimeFormat.Calendar = hijri3;
            dFormat3 = current3.DateTimeFormat.ShortDatePattern;
            // Ensure year is displayed as four digits.
            dFormat3 = Regex.Replace(dFormat3, "/yy$", "/yyyy") + " H:mm:ss.fff";
            fmtString3 = "{0} culture using the {1} calendar: {2:" + dFormat3 + "} {3}";
            DateTime date8 = new DateTime(1431, 9, 9, 16, 32, 18, 500,
                                          hijri3, DateTimeKind.Local);
            Console.WriteLine(fmtString3, current3, GetCalendarName(hijri3),
                              date8, date8.Kind);

            // Restore previous culture.
            Thread.CurrentThread.CurrentCulture = dftCulture3;
            dFormat3 = DateTimeFormatInfo.CurrentInfo.ShortDatePattern + " H:mm:ss.fff";
            fmtString3= "{0} culture using the {1} calendar: {2:" + dFormat3 + "} {3}";
            Console.WriteLine(fmtString3,
                              CultureInfo.CurrentCulture,
                              GetCalendarName(CultureInfo.CurrentCulture.Calendar),
                              date8, date8.Kind);
            /*
             Using the Persian Calendar:
             6/19/2018 4:32:18.500 下午 Local
             3/29/1397 16:32:18.500 Local

             Using the Hijri Calendar:
             ar-SY culture using the Hijri calendar: 09/09/1431 16:32:18.500 Local
             zh-CN culture using the Gregorian calendar: 2010/8/18 16:32:18.500 Local
             */
            Console.ReadKey();
        }
        private static string GetCalendarName(Calendar cal)
        {
            return Regex.Match(cal.ToString(), "\\.(\\w+)Calendar").Groups[1].Value;
        }
    }
}

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前言 有時候必須在伺服器上調試代碼。比如做微信公眾號開發,需要做一些url回調, 此時無法在開發電腦上做調試。所以遠程調試代碼就很有必要了。經過2個小時摸索,順利實現。 (註意:用jexus時無法遠程調試,因為jexus隱藏了dotnet進程,它把dotnet作為自己的子進程,所以無法附加dotne ...
  • 一,安裝 最近在用 Visual Studio Code 學習.net core ,記錄下學習的過程,首先去官網下載最新的.net core2.1安裝包,有windows 和mac,根據自己的開發環境而定。如下圖,剛安裝完成並不是這樣的,需要在擴展 Ctrl+Shift+X 中安裝漢化包, Wind ...
  • 概述Visual studio 項目允許在項目屬性生成事件一欄中指定預先生成和後期生成事件來實現項目生成與部署的自動化。Microsoft Ref:預生成事件/生成後事件命令行對話框Microsoft Ref: 如何:指定生成事件 (C#)Ref:C# XCOPY命令 “預先生成事件命令行”和“後期... ...
  • 紙殼CMS是一個開源免費的,可視化設計,線上編輯的內容管理系統。基於ASP .Net Core開發,插件式設計的CMS系統 ...
  • RoadFlow新建一個流程分為以下幾步: 1、建表 在資料庫建一張自己的業務表(根據你自己的業務需要確定表欄位,如請假流程就有,請假人、請假時間、請假天數等欄位),數據表必須要有一個主鍵,主鍵類型是(int自增,或者guid(uniqueidentifier)類型)。 2、設計表單。 在流程管理- ...
  • RoadFlow最新版本採用ASP.NET CORE2.1開發,部署步驟和.NET CORE部署一樣,具體可參數ASP.NET CORE的部署方式。 1、 獲取代碼 首先從RoadFlow官網下載最新版本代碼(下載連接:http://www.roadflow.net/Download)。 下載後解壓 ...
  • 學習asp.net 已經有近三個月的時間了,在asp.net mvc上花的時間最多,但個人真是有些菜,不得不說,asp.net mvc的水真的還是蠻深的。目前在公司實習,也見過公司幾個項目的代碼了。對項目的代碼始終停留在一知半解的地步,能改一些簡單的bug,但關於項目的來龍去脈始終雲里霧裡。對於as ...
  • .Net平臺下相容.NET Standard 2.0,一個實現以Lambda表達式轉轉換標準SQL語句,使用強類型操作數據的輕量級ORM工具,在減少魔法字串同時,通過靈活的Lambda表達式組合,實現業務數據查詢的多樣性 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...