Time of Update: 2018-12-07
當Office 2007來的時候,C#串連EXCEL,串連引擎發生了變化,對於2007和2010來說,串連引擎是Microsoft.ACE.OLEDB.12.0,所以在這兩個下的練級字串為: OleDbConnection con = new OleDbConnection(); con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + fileName + ";" +
Time of Update: 2018-12-07
今天看程式員面試寶典發現了一個問題。在P37的例子中,寶典認為>>比~的優先順序高。這是錯誤的。實際上~比>>的優先順序高。程式碼如下: #include <iostream>using namespace std;int main(){ unsigned char a=0xA5; unsigned char b=~a>>4; printf("b=%d\n",b); system("PAUSE");
Time of Update: 2018-12-07
靜態建構函式用於初始化任何待用資料,或用於執行僅需執行一次的特定操作。在建立第一個執行個體或引用任何靜態成員之前,將自動調用靜態建構函式。Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class SimpleClass{ // Static constructor static SimpleClass() { //
Time of Update: 2018-12-07
1 What will happen after running the "Test"?Code highlighting produced by Actipro CodeHighlighter
Time of Update: 2018-12-07
對於++、--運算子,我們應注意以下幾點:(1)++、--運算子只能用於變數,而不能用於常量或運算式,例如8++,(x+y)--均是不合法的。(2)++、--運算子是單目運算子,優先順序高於雙目基本算術運算子,而低於括弧( ( )
Time of Update: 2018-12-07
using 語句(C# 參考)Visual Studio 2005 其他版本 Visual Studio 2010 Visual Studio 2008 Visual Studio 2012 32(共 46)對本文的評價是有協助 - 評價此主題 定義一個範圍,將在此範圍之外釋放一個或多個對象。文法 複製 using (Font font1 = new Font("Arial", 10.0f)){}備忘 C# 通過 .NET Framework 公用語言運行庫 (CLR)
Time of Update: 2018-12-07
C#非同步編程有四種方式,可參考下面的文章MSDN-非同步編程概述 [C#] 並且在MSDN協助文檔中也有相關介紹MSDN:ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpgenref/html/cpconasynchronousexecution.htm 另外這樣也可以實現相同的效果(我還沒有使用過): //System.Threading.ThreadPool.QueueUserWorkItem(new
Time of Update: 2018-12-07
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using Microsoft.Office.Interop.Excel;using System.Data.SqlClient;using
Time of Update: 2018-12-07
今天我們同學問我如何利用C#把剪貼簿裡的圖片存出來,我看了看,非常簡單IDataObject data = Clipboard.GetDataObject();//從剪貼簿中擷取資料if(data.GetDataPresent(typeof(Bitmap)))//判斷是否是圖片類型{ Bitmap map = (Bitmap) data.GetData(typeof(Bitmap));//將圖片資料存到位元影像中 this.pictureBox1.Image = map;
Time of Update: 2018-12-07
優先順序類別運算子1基本(x) x.y f(x) a[x] x++ x――new typeof sizeof checked unchecked 2單目+ - ! ~ ++x ――x (T)x3乘法與除法* / %4加法與減法+ -5移位元運算≤ ≥6關係運算﹤ > <= &
Time of Update: 2018-12-07
引入:經常見有這樣的類:如aClass a = new Class();然後在程式裡出現個a[i]="some string";感覺好奇怪:既然沒有聲明類數組卻用[]索引,而且返回個string類型,索引器概述:簡單說來,所謂C#索引器就是一類特殊的屬性,通過它們你就可以像引用數組一樣引用自己的類。索引器使得對象可按照與數組相似的方法進行索引。get 訪問器傳回值。set 訪問器分配值。this 關鍵字用於定義索引器。value 關鍵字用於定義由 set
Time of Update: 2018-12-07
當我糾結於怎麼輸出n個空格的時候, 一個內建方法輕描淡寫地就把問題給解決了: cout<<setw(n)<<n<<endl; 列印n個空格(為了辨別,後面加了一個字母n)不過要加#include <iomanip>下面做一個簡單的練習:列印一個菱形框實現方法如下:View Code 1 #include "stdafx.h" 2 #include <iomanip> 3 #include <iostream> 4
Time of Update: 2018-12-07
string不變 stringbuilder可變C#語言還是比較常見的東西,這裡我們主要介紹C# StringBuilder和String,包括介紹大量字串拼接或頻繁對某一字串進行操作時最好使用 StringBuilder,不要使用 String等方面。C# StringBuilder和String區別String 在進行運算時(如賦值、拼接等)會產生一個新的執行個體,而 StringBuilder 則不會。所以在大量字串拼接或頻繁對某一字串進行操作時最好使用
Time of Update: 2018-12-07
自訂屬性的作用 有時候我們需要給一個類或者類中的成員加上一些屬性或者附加資訊,讓類或者變數的功能更明確可控制的細粒度更高,打個簡單的比方:資料庫裡面的一張表,表中的每一個欄位都有很多屬性,如是否主鍵,預設值,注釋資訊等等,我們在編寫實體類的時候,如何表示這些資訊呢?通過自訂屬性可以實現。自訂屬性的實現步驟1、聲明一個類,並將 AttributeUsageAttribute 屬性應用到該類中。類的名稱即為新屬性的名稱 2、聲明該類從 System.Attribute 繼承: 3、定義
Time of Update: 2018-12-07
1,說明:先添加COM對像的引用:右擊References => Add Reference => COM => 填加Microsoft Excel 11.0 Object
Time of Update: 2018-12-07
下面這樣類似的代碼:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->?1if ( strParam== null ){ strParam= "";}與這樣的代碼:?1string strParam= Request.Params["param"] == null ? "" :
Time of Update: 2018-12-07
http://developer.51cto.com/art/200908/148353.htm在發布Visual Studio 2005和C#2.0之後,微軟公司又馬不停蹄的展示了人們所期望的C#的下一代版本:C# 3.0。儘管C# 3.0並沒有標準化,微軟還是在PDC(專業程式員會議)發布了一個預覽版本,因此心急的程式員可以看到一些所期望的Visual C#
Time of Update: 2018-12-07
http://qing.weibo.com/tj/400082fa33001h7x.html1.5 實現依賴注入1.5.1 背景介紹
Time of Update: 2018-12-07
http://www.cnblogs.com/JeffreyZhao/archive/2009/08/07/1540866.htmlNET 3.5中委託的寫法(Lambda運算式) Lambda運算式在C#中的寫法是“arg-list => expr-body”,“=>”符號左邊為運算式的參數列表,右邊則是運算式體(body)。參數列表可以包含0到多個參數,參數之間使用逗號分割。例如,以下便是一個使用Lambda運算式定義了委託的樣本1:Func<int, int, int&
Time of Update: 2018-12-07
今天寫了個