Time of Update: 2018-12-05
指標的接入有兩種方式,1.C#中的參考型別2.C#中的指標實現using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.InteropServices;/// <summary> /// 離線UK操作類 /// </summary> public unsafe class UK {
Time of Update: 2018-12-05
access不像sqlserver,oracle有提供直接的系統資料表,可以查詢相關表的列資訊,因此直接用sql無法尋找到相關資訊,需要通過程式實現。代碼如下:public static DataSet GetOleDbColumns(DBlink dbLink, string tableName) { DBHelperOleDb.connectionString = dbLink.linkConnStr; DataTable
Time of Update: 2018-12-05
上面為綁定圖片顯示資訊,以下為改變選擇時候修改複選框狀態: /// <summary> /// 設定單位樹改變複選框狀態 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void
Time of Update: 2018-12-05
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using
Time of Update: 2018-12-05
修改註冊表後不重啟電腦並生效。const int WM_SETTINGCHANGE = 0x001A; const int HWND_BROADCAST = 0xffff;IntPtr result1;public enum SendMessageTimeoutFlags : uint { SMTO_NORMAL = 0x0000, SMTO_BLOCK = 0x0001, SMTO_ABORTIFHUNG = 0x0002, SMTO_NOTIMEOUTIFNOTHUNG = 0x0008 }
Time of Update: 2018-12-05
實值型別本來是有預設值的,初始化時不能賦值為null,否則編譯時間會報錯.net 2.0以後增加了可空類型。int? a,float? b,double? c, DateTime? d,bool? e為可空類型,此時a=null,不會報錯。判斷時也可以用if(a==null)進行判斷。聲明可空類型的兩種方式:int ? a,Nullable<int>
Time of Update: 2018-12-05
C#Winform中儲存配置資訊App.Config的類操作:添加引用:System.Configuration;/// <summary> /// 配置資訊維護 /// </summary> public class AppConfig { public static Configuration config =
Time of Update: 2018-12-05
位操作符是對資料按二進位位進行運算的操作符。c#位操作符包括:按位與 &按位或 |按位取反 ~左移 <<右移 >>舉例說明public static void Main() { int a=6&3; Console.WriteLine("a={0}",a); //6的二進位是00000110,3的二進位是00000011,按位與後等於00000010, 即2。 int b=6|3;
Time of Update: 2018-12-05
C#遍曆結構體 Type type = typeof(Color); PropertyInfo[] fields = type.GetProperties(); //FieldInfo[] fields =type.GetFields(System.Reflection.BindingFlags.Public|System.Reflection.BindingFlags.Static); int i = 30
Time of Update: 2018-12-05
c#的欄位就是指私人域(變數)class A{int i;public int I{get{....}set{....}} }其中,i是欄位,I是屬性, 欄位是屬於一個類的,在類中定義(注意:是類中,而不是類中的某個方法或屬性中)在本類中可以用this.欄位名訪問且本類中的所有屬性、方法等都可以訪問也就是說它的範圍是整個類。而局部變數是屬於一個函數或語句塊的它的範圍是從定義開始,到離開語句塊。 C#中的變數、欄位、域、屬性、屬性過程在C#中: 域:
Time of Update: 2018-12-05
綁定樹節點及表徵圖狀態如下: /// <summary> /// 綁定資料上報匯出樹 /// </summary> private void BindJgsyTree() { JGSYTreeService jgsyTreeService = new JGSYTreeService(); List<JGSYTree> listJgsyTree =
Time of Update: 2018-12-05
建立表:create table [表名]([自動編號欄位] int IDENTITY (1,1) PRIMARY KEY ,[欄位1] nVarChar(50) default '預設值' null ,[欄位2] ntext null ,[欄位3] datetime,[欄位4] money null ,[欄位5] int default 0,[欄位6] Decimal (12,4) default 0,[欄位7] image null ,)刪除表:Drop table
Time of Update: 2018-12-05
檢測office的應用程式的版本,public class OfficeVersion { /// <summary> /// 擷取Access的提供者 /// </summary> /// <returns>是否設定成功</returns> public static string GetAccessProvider() {
Time of Update: 2018-12-05
偶然在C#中看到內部類,即在類的內部定義類,例如:System.Windows.Forms.Control類中又有ControlCollection,ControlAccessibleObject類的定義,內部類的定義是為了供給該類自身使用,外部類無法進行使用,作用是:使內部類的可見度更小可參考如下執行個體:namespace DesignPattern.InnerClass{ /// <summary> /// 外部類 /// </summary>
Time of Update: 2018-12-05
壓縮和解壓縮分為:單一檔案壓縮和整個檔案夾壓縮,其中檔案夾壓縮現在還沒實現遞迴檔案夾,現已夠用測試通過,代碼如下:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.IO.Compression;using System.Collections;using
Time of Update: 2018-12-05
//Stream是一個抽象類別,不能直接執行個體化 //FileStream繼承於Stream ,讀寫檔案流 //StreamWriter繼承於TextWriter(抽象類別,繼承於MarshalByRefObject, IDisposable),可以操作Stream //StreamReader繼承於TextReader(抽象類別,繼承於MarshalByRefObject,
Time of Update: 2018-12-05
在C/C++中,struct類型中的成員的一旦聲明,則執行個體中成員在記憶體中的布局(Layout)順序就定下來了,即與成員聲明的順序相同,並且在預設情況下總是按照結構中佔用空間最大的成員進行對齊(Align);當然我們也可以通過設定或編碼來設定記憶體對齊的方式.
Time of Update: 2018-12-05
1.首先將引用添加到項目中,可以放在BLL層也可以放在UI層。2.在UI層或設定檔中設定連結URL或者設定資料庫中動態讀取。3.做一個類用來配置webservice的訪問:/// <summary> /// 與BS資料交換的介面 /// </summary> public static class DataTransfer { static DataTransferWS client; ///
Time of Update: 2018-12-05
因為程式是放在Ukey(隨身碟)中運行,不是Setup打包程式,所以啟動時如果未安裝Framework不能直接運行.net的exe啟動程式,解決方案是:由C++寫的Startup.exe做啟動程式,同時檢測本機是否安裝Framework,如果沒有則有c++調用啟動安裝,安裝Framework結束後,啟動C#應用程式。其中C++的檢測安裝啟動程式碼如下,VC++6.0實現,做了一個隱藏的form表單: // StartUpDlg.cpp : implementation
Time of Update: 2018-12-05
TreeList控制項的節點表徵圖設定,在顯示內容裡要麼設定為全部顯示,要麼全部不顯示。當前項目需求為,個別節點設定為不可用,個別節點設定為只顯示線不顯示選擇框,由此只能拋棄treelist自身的checkbox顯示設定,自己畫表徵圖。利用StateImage屬性設定表徵圖顯示,首先做一個表徵圖的枚舉,從資源檔裡讀取:/// <summary> /// TreeList頁節點選擇狀態 /// </summary> public enum