生活随笔
收集整理的這篇文章主要介紹了
代码片_笔记
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
.NET //事件類,定義事件訂閱消息及觸發事件public class TempterLisenting{//public event EventHandler<WaterTempterEventAgrs> WaterEvent;public delegate void WaterEventHandler(object sender, WaterTempterEventAgrs e);public event WaterEventHandler WaterEvent;public void WaterTempterAdd(int waterTempter){if (WaterEvent != null){WaterEvent(this, new WaterTempterEventAgrs(waterTempter));}}}//客戶類,事件訂閱者public class Listener{public void IsWaterBoiling(object sender, WaterTempterEventAgrs e){if (e.WaterTempter >= 90 && e.WaterTempter <= 99){Console.WriteLine("the water is will boiling:{0}", e.WaterTempter);}else if (e.WaterTempter == 100){Console.WriteLine("the water is boiling:{0}", e.WaterTempter);}}public void Register(TempterLisenting listener){listener.WaterEvent += IsWaterBoiling;}}*******************public class WaterTempterPublish{public delegate void WaterTempterDel(int tempter);public event WaterTempterDel waterTempterevent;public void WatreTempterAdd(int tempter){if (waterTempterevent != null){waterTempterevent(tempter);}}}public class WaterTempterListening{public void IsWaterBoiling(int tempter){if (tempter < 100){Console.WriteLine("the waterTempter is :{0}", tempter);}else if (tempter == 100){Console.WriteLine("the water is Boiling,Now the waterTempter is :{0}", tempter);}}public void Register(WaterTempterPublish waterTemprerPublish){waterTemprerPublish.waterTempterevent += IsWaterBoiling;}}
namespace CodeSample
{public delegate void BookDelegate(string bookName, string bookType);public class Custormers{private string custormerName;private string custormerBooktype;public string CustormerName{get { return custormerName; }set { custormerName = value; }}public string CustormerBooktype{get { return custormerBooktype; }set { custormerBooktype = value; }}public Custormers(string m_custormerName, string m_custormerBooktype){custormerBooktype = m_custormerBooktype;custormerName = m_custormerName;}public void Registre(BookStore bookStore){bookStore.BookDelegate += BookStore_BookDelegate;}void BookStore_BookDelegate(string bookName, string bookType){if (bookType == CustormerBooktype){Console.WriteLine("{0},您好。您在本店預約的書類為\"{1}\"的書籍<<{2}>>到貨了。", custormerName, bookType, bookName);}}}public class BookStore{public event BookDelegate BookDelegate;public void NewBook(string bookName, string bookType){BookDelegate(bookName, bookType);}}public class CodeSampleMain{public static void Main(){BookStore bookStore = new BookStore();Custormers[] custormer = new Custormers[3];custormer[0] = new Custormers("黃**", "計算機");custormer[1] = new Custormers("二少", "英語");custormer[2] = new Custormers("**杰", "玄幻小說");for (int i = 0; i < custormer.Length; i++){custormer[i].Registre(bookStore);}bookStore.NewBook("計算機組成原理", "計算機");bookStore.NewBook("走遍美國", "英語");bookStore.NewBook("紫川", "玄幻小說");Console.ReadKey();}}
}
JavaScript (function () {var $ = (function () {function f(selector, context) {return f.prototype.init(selector, context);}f.prototype.init = function (selector, context) {context = context || document;var nodeList = context.querySelectorAll(selector);this.length = nodeList.length;this.elements = [];for (var i = 0; i < this.length; i++) {this.elements[i] = nodeList[i];}return this;};return f;})();window.$ = $;
})();
(function (window, undefined) {var jQuery = (function () {// 構建jQuery對象var jQuery = function (selector, context) {return new jQuery.fn.init(selector, context, rootjQuery);};// jQuery對象原型jQuery.fn = jQuery.prototype = {constructor : jQuery,init : function (selector, context, rootjQuery) {// selector有以下7種分支情況:// DOM元素// body(優化)// 字符串:HTML標簽、HTML字符串、#id、選擇器表達式// 函數(作為ready回調函數)// 最后返回偽數組}};//把jQuery的prototype賦值給init方法的prototypejQuery.fn.init.prototype = jQuery.fn;// 合并內容到第一個參數中,后續大部分功能都通過該函數擴展// 通過jQuery.fn.extend擴展的函數,大部分都會調用通過jQuery.extend擴展的同名函數jQuery.extend = jQuery.fn.extend = function () {};// 在jQuery上擴展靜態方法jQuery.extend({// ready bindReady// isPlainObject isEmptyObject// parseJSON parseXML// globalEval// each makeArray inArray merge grep map// proxy// access// uaMatch// sub// browser});return jQuery;})();window.jQuery = window.$ = jQuery;
})(window);
SQL CREATE TABLE [aaa]([id] [int] NULL,[pid] [int] NULL,[name] [nchar](10)
)
GOINSERT INTO aaa VALUES(1,0,'a')INSERT INTO aaa VALUES(2,0,'b')INSERT INTO aaa VALUES(3,1,'c')INSERT INTO aaa VALUES(4,1,'d')INSERT INTO aaa VALUES(5,2,'e')INSERT INTO aaa VALUES(6,3,'f')INSERT INTO aaa VALUES(7,3,'g')INSERT INTO aaa VALUES(8,4,'h')
GO
下面的Sql是查詢出1結點的所有子結點
with my1 as(select * from aaa where id = 1union all select aaa.* from my1, aaa where my1.id = aaa.pid
)
select * from my1 --結果包含1這條記錄,如果不想包含,可以在最后加上:where id <> 1
下面的Sql是查詢出8結點的所有父結點
with my1 as(select * from aaa where id = 8union all select aaa.* from my1, aaa where my1.pid = aaa.id
)
select * from my1;
下面是遞歸刪除1結點和所有子結點的語句
with my1 as(select * from aaa where id = 1union all select aaa.* from my1, aaa where my1.id = aaa.pid
)
delete from aaa where exists (select id from my1 where my1.id = aaa.id)
轉載于:https://www.cnblogs.com/wipphj/p/4556410.html
《新程序員》:云原生和全面數字化實踐 50位技術專家共同創作,文字、視頻、音頻交互閱讀
總結
以上是生活随笔 為你收集整理的代码片_笔记 的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網站內容還不錯,歡迎將生活随笔 推薦給好友。