foreach可以迭代一些.net本來就為我們做好的類型,比如int,string等等但是如果想迭代自己的類,就必須自己來寫了首先就要先實現IEnumerator的幾個方法,和IEnumerable的GetEnumerator()方法 代碼 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->foreach(person p in persons){
代碼Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> class Point : IFormattable { public int x, y; public Point(int x, int y) { this.x = x; this.y = y;
無意中看到個英文部落格,說老實話還從來沒嘗試過閱讀英文文章今天居然“鼓起勇氣”一口氣看完,而且越看越順,這位老師的用語感覺還是很簡單的。。 我還挺高興的。。 Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as sealed class, this class cannot be inherited.In C#,
以前一直看到方法列表中有種方法的表徵圖是 普通方法的紅立方體右邊還有個箭頭就像這樣 ,原來這種方法就是擴充方法 擴充方法不能訪問它擴充的類型的私人成員。調用擴充方法只是調用靜態方法的一種新文法代碼Code highlighting produced by Actipro CodeHighlighter
public bool InsertAdmin(string userName, string password, string remark, string mail, int departId, int power)ÆïǾLâ½íwww.netcsharp.cnQfòç=û\ { string sql = "insert into
如果有一個person的類型數組,需要排序,我們想按年齡排序則使用如下方法 Array.sort(list,(p1,p2)=>p1.age.CompareTo(p2.age));以前知道,自訂排序需要讓自己的類實現IComparer介面,寫出自己的定序 可是,傳遞一個委託變數進去(這裡用的lamda運算式),.net是如何為我們排序的呢?請看 ReflectorCode highlighting produced by Actipro CodeHighlighter
春節比較閑,剛學了一點linq to sql,打算做個小財務系統練下手介面用coolite,使用者體驗比較好,只看了效果,剛把控制項下載下來,一點不會,邊做邊學吧系統就是做給外行用的,表面功夫是一定要到位滴 我直接把linq to sql產生的程式碼作為實體 下面是項目中遇到的問題,不斷更新 問題一:在做使用者登入判斷密碼時,如果資料庫裡沒有該記錄(輸入錯誤)if (fdc.UserInfo.Single(c => c.UserName == name &&
IFEXISTS(SELECTnameFROMdbo.sysobjectsWHEREid=Object_id(N'[dbo].[row_count]')) DROPFUNCTION[dbo].[row_count] GO CREATEFUNCTIONdbo.row_count(@table_namesysname) --@table_namewewanttogetcount RETURNSbigint AS BEGIN DECLARE@nnbigint--numberofrows