亚洲乱色熟女一区二区三区丝袜,天堂√中文最新版在线,亚洲精品乱码久久久久久蜜桃图片,香蕉久久久久久av成人,欧美丰满熟妇bbb久久久

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開(kāi)發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

C# this關(guān)鍵字的3種用法

admin
2024年3月28日 22:12 本文熱度 1667

用法一  this代表當(dāng)前類(lèi)的實(shí)例對(duì)象

namespace Demo{    public class Test    {        private string scope = "全局變量";        public string getResult()        {            string scope = "局部變量";       // this代表Test的實(shí)例對(duì)象       // 所以this.scope對(duì)應(yīng)的是全局變量        // scope對(duì)應(yīng)的是getResult方法內(nèi)的局部變量            return this.scope + "-" + scope;        }    }
   class Program    {        static void Main(string[] args)        {            try            {                Test test = new Test();                Console.WriteLine(test.getResult());            }            catch (Exception ex)            {                Console.WriteLine(ex);            }            finally            {                Console.ReadLine();            }
       }    }}

用法二  用this串聯(lián)構(gòu)造函數(shù)

namespace Demo{    public class Test    {        public Test()        {            Console.WriteLine("無(wú)參構(gòu)造函數(shù)");        }        // this()對(duì)應(yīng)無(wú)參構(gòu)造方法Test()     // 先執(zhí)行Test(),后執(zhí)行Test(string text)        public Test(string text) : this()        {            Console.WriteLine(text);            Console.WriteLine("有參構(gòu)造函數(shù)");        }    }
   class Program    {        static void Main(string[] args)        {            try            {                Test test = new Test("張三");            }            catch (Exception ex)            {                Console.WriteLine(ex);            }            finally            {                Console.ReadLine();            }        }    }}

用法三  為原始類(lèi)型擴(kuò)展方法

namespace Demo{    public static class Extends    {     // string類(lèi)型擴(kuò)展ToJson方法        public static object ToJson(this string Json)        {            return Json == null ? null : JsonConvert.DeserializeObject(Json);        }        // object類(lèi)型擴(kuò)展ToJson方法        public static string ToJson(this object obj)        {            var timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };            return JsonConvert.SerializeObject(obj, timeConverter);        }        public static string ToJson(this object obj, string datetimeformats)        {            var timeConverter = new IsoDateTimeConverter { DateTimeFormat = datetimeformats };            return JsonConvert.SerializeObject(obj, timeConverter);        }        public static T ToObject<T>(this string Json)        {            return Json == null ? default(T) : JsonConvert.DeserializeObject<T>(Json);        }        public static List<T> ToList<T>(this string Json)        {            return Json == null ? null : JsonConvert.DeserializeObject<List<T>>(Json);        }        public static DataTable ToTable(this string Json)        {            return Json == null ? null : JsonConvert.DeserializeObject<DataTable>(Json);        }        public static JObject ToJObject(this string Json)        {            return Json == null ? JObject.Parse("{}") : JObject.Parse(Json.Replace(" ", ""));        }    }
   class Program    {        static void Main(string[] args)        {            try            {                List<User> users = new List<User>{                    new User{ID="1",Code="zs",Name="張三"},                    new User{ID="2",Code="ls",Name="李四"}                };
               // list轉(zhuǎn)化json字符串                string json = users.ToJson();          // string轉(zhuǎn)化List                users = json.ToList<User>();
               // string轉(zhuǎn)化DataTable                DataTable dt = json.ToTable();            }            catch (Exception ex)            {                Console.WriteLine(ex);            }            finally            {                Console.ReadLine();            }        }    }
   public class User    {        public string ID { get; set; }        public string Code { get; set; }        public string Name { get; set; }    }}

該文章在 2024/3/28 22:12:22 編輯過(guò)
關(guān)鍵字查詢(xún)
相關(guān)文章
正在查詢(xún)...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專(zhuān)業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國(guó)內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場(chǎng)、車(chē)隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場(chǎng)作業(yè)而開(kāi)發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類(lèi)企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉(cāng)儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷(xiāo)售管理,采購(gòu)管理,倉(cāng)儲(chǔ)管理,倉(cāng)庫(kù)管理,保質(zhì)期管理,貨位管理,庫(kù)位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶(hù)的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved