Time of Update: 2016-03-11
標籤:一、類型轉換二、可變參數三、字串四、委託五、建構函式六、Lamba運算式七、Linq八、Entity Framework 1.程式的入口:Entities 檔案尾碼Context.cs 2.資料庫的相關資訊都在產生的一個與資料庫表對應的類中 檔案資料庫名.tt中的表名(一般EF的名字和資料庫的名字或者項目的名字相同後面加DB) 3.EF對資料庫進行增刪查改 增:
Time of Update: 2016-03-08
標籤:switch語句using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace @switch{ class Program { static void Main(string[] args) { for (; ; ) {
Time of Update: 2016-03-08
標籤:12345678910111213141516171819202122232425262728293031323334353637Console.Write("女:你有房子麼"); string yes =
Time of Update: 2016-03-07
標籤:迭代器迭代器是作為一個容器,將要遍曆的資料放入,通過統一的介面返回相同類型的值迭代器代碼使用 yield return 語句依次返回每個元素。yield break 將終止迭代類中實現多個迭代器。每個迭代器都必須像任何類成員一樣有唯一的名稱迭代器的傳回型別必須為 Ienumerable(整形介面)、IEnumerator、IEnumerable<T>
Time of Update: 2016-03-09
標籤: //順序 選擇 迴圈 //迴圈 for //for (; ; ) //死迴圈 //{ //} //break跳出迴圈體 //continue結束本次迴圈,繼續下次迴圈 //列印20遍你好 //for (int a=1;a<=20 ;a++ ) //{
Time of Update: 2016-03-07
標籤:管理-->事件檢視器 可以查看【應用程式】、【安全】、【系統】等分類的日誌1234567891011121314151617181920212223static void Main(string[] args){ EventLog eventlog = new EventLog(); eventlog.Log = "Security";
Time of Update: 2016-03-09
標籤:轉,原文地址:http://blog.csdn.net/yanlele424/article/details/73293891.擷取和設定目前的目錄的完全限定路徑。string str = System.Environment.CurrentDirectory; Result: C:xxxxxx2.擷取啟動了應用程式的可執行檔的路徑,不包括可執行檔的名稱。string str = System.Windows.Forms.Application.StartupPath;Result: C:
Time of Update: 2016-03-05
標籤:下面首先來說說簡單工廠 舉個例子:首先是父類 public abstract class Pizza { public abstract string Info(); }}子類 public class CheesePizza:Pizza { public override string Info() { return "您好,乳酪比薩成功訂購"; } }下一個子類public
Time of Update: 2016-03-02
標籤:在C#中定義常量的方式有兩種,一種叫做靜態常量(Compile-time constant),另一種叫做動態常量(Runtime constant)。前者用“const”來定義,後者用“readonly”來定義。 對於靜態常量(Compile-time constant),它的書寫方式如下: public const int MAX_VALUE = 10;
Time of Update: 2016-03-08
標籤: // 按比例縮放圖片 public Image ZoomPicture(Image SourceImage, int TargetWidth, int TargetHeight) { int IntWidth; //新的圖片寬 int IntHeight; //新的圖片高 try { System.Drawing.
Time of Update: 2016-03-06
標籤:資料類型using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace shujuleixing{ class Program { static void Main(string[] args) { ////資料類型
Time of Update: 2016-03-04
標籤:private Stopwatch wath = new Stopwatch(); /// <summary> /// 使用COM讀取Excel /// </summary> /// <param name="excelFilePath">路徑</param> /// <returns>DataTabel</returns>
Time of Update: 2016-03-01
標籤:用c#從百萬資料中篩選一些資訊時,經常會出現程式連線逾時的錯誤,常見的錯誤很多,例如:Timeout expired. The timeout period elapsed prior to completion of the operation or the server等等 本文就常見的幾種解決方案進行說明,純屬個人見解,歡迎拍磚
Time of Update: 2016-03-04
標籤:1、選擇檔案用OpenDialogOpenFileDialog dialog = new OpenFileDialog();dialog.Multiselect = true;//該值確定是否可以選擇多個檔案dialog.Title = "請選擇檔案夾";dialog.Filter = "所有檔案(*.*)|*.*";if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK){ string file =
Time of Update: 2016-03-01
標籤: public List<string> ReadtxtInfo() { FileStream fs = new FileStream(System.Web.HttpContext.Current.Server.MapPath("/") + @"/AllowList.txt", FileMode.Open); StreamReader m_streamReader = new StreamReader(fs);
Time of Update: 2016-03-04
標籤:最近研究C#,發現寫代碼很麻煩,特別是建立實體、模型、介面、工廠、預存程序之類,網上有些開源的,但是不完整,也不能完整的按需求產生,於是,花了三天的時候,結合前輩的一些經驗,整合了一些代碼產生器,以下是預存程序的產生方法,可以借鑒一下,水平有限,請多指教。 1 /// <summary> 2 /// 建立預存程序 3 /// </summary> 4 public string
Time of Update: 2016-03-01
標籤:最近又再看基礎知識了。看到方法的重寫(new)和覆蓋(override)的時候有點不太懂。於是百度之。那答案啊。。。。。要麼就是把覆蓋(override)和重載(overlord)混淆了。要麼就是把重寫(new)和覆蓋(override)說反了。最後不得已Google之。在stackoverflow裡看到一個比較好的答案:-------------------------------------------------------------------------------------
Time of Update: 2016-03-01
標籤:在使用TabControl控制項時,希望隱藏其中某個選項卡(即TabPage)。TabPage類明明提供了一個Hide方法,用在代碼中卻沒有任何效果,甚是奇怪。無奈之餘,只好考慮另闢途徑。方法一:設定該TabPage的父容器為null 即可,如TabPage.Parent = null 。如需顯示該TabPage,設定其父容器為對應的TabControl即可。方法二:利用TabControl的TabPages屬性,它是TabPage對象的集合,調用集合的Remove(TabControl.
Time of Update: 2016-03-03
標籤:一、先來看看最常見的匯入操作吧!private void Import(){ //開啟excel選擇框 OpenFileDialog frm = new OpenFileDialog(); frm.Filter = "Excel檔案(*.xls,xlsx)|*.xls;*.xlsx"; if (frm.ShowDialog() == DialogResult.OK) {
Time of Update: 2016-03-02
標籤:sed今天一個群友在群裡提問的a.b.c.d.e.f.g正則處理一下變成d.e.f.g總結了幾種方法首先就是cut大法[email protected]:/tmp/tmp# echo a.b.c.d.e.f.g|cut -d"." -f4,5,6,7d.e.f.g絕對好用、但不推薦。。接下來就是sed了,還挺好用的[email protected]:/tmp/tmp# echo a.b.c.d.e.f.g|se