Time of Update: 2018-12-06
1. 在使用者的配置時,我們需要列出當前區域網路內所有的資料庫伺服器,並且要列出指定伺服器的所有資料庫,實現代碼如下:取得資料庫伺服器列表: public ArrayList GetServerList() { ArrayList alServers = new ArrayList() ; SQLDMO.Application sqlApp = new SQLDMO.ApplicationClass() ; try { SQLDMO.NameList serverList =
Time of Update: 2018-12-06
//上移private void ListViewUpMove(ListView listView) { if (listView.SelectedItems.Count == 0) { return; } listView.BeginUpdate(); if (listView.SelectedItems[0].Index > 0)
Time of Update: 2018-12-06
using System;using System.Collections.Generic;using System.Text;using System.Net;//為了IPEndPoint而添加的引用using System.Net.Sockets;namespace GetClntIP{ class Program { static void Main(string[] args) { TcpListener
Time of Update: 2018-12-06
1、獲得當前按鍵:private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e){ if(e.KeyCode.ToString ( )=="Enter") { MessageBox.Show ( e.KeyCode.ToString ( ) , "您所按動的健為:" ) ; }} 2、DateTime 數字型 System.DateTime
Time of Update: 2018-12-06
一、準備需要的軟體:Ildasm.exe:用來將dll,exe編譯為IL檔案ilasm.exe:用來將IL檔案編譯回來dll或exe這2個工具裝好VS就有了(VS2005的可以處理2003的,反過來不行)文本處理工具:UltraEdit :http://www.crsky.com/soft/1469.htmlEmEditorPro:http://www.crsky.com/soft/4278.html根據不同情況需要使用上面不同的工具其他工具:Reflector.exe :http://www.
Time of Update: 2018-12-06
IndexOf() 尋找字串中指定字元或字串首次出現的位置,返首索引值,如: str1.IndexOf("字"); //尋找“字”在str1中的索引值(位置) str1.IndexOf("字串");//尋找“字串”的第一個字元在str1中的索引值(位置)
Time of Update: 2018-12-06
獲得當前電腦系統內所有的已啟動的進程:System.Diagnostics.Process[] processOnComputer = System.Diagnostics.Process.GetProcesses();foreach ( System.Diagnostics.Process p in processOnComputer
Time of Update: 2018-12-06
當sizeof應用於指標數組時。如果應用於數組名稱時,將返回整個數組佔用的位元組總數。當應用於帶有適當索引的元素時,將返回該元素佔用的位元組數量。在VS 2010 中編寫以下程式#include "stdafx.h"#include <iostream>using std::cout;using std::cin;using std::endl;int _tmain(int argc, _TCHAR* argv[]){ char *pstr[]={"test1","test2"
Time of Update: 2018-12-06
原因:在C++函式宣告時要將 extern "C" 添加在 DLL 函式宣告之前。[DllImport("a.dll")] public extern static int F(); 調用後提示找不到進入點 在命令列用dumpbin /exports 看函數名: ,或用exeScope查看匯出的介面dumpbin /exports a.dll 函數名不是"F"?而是"?F@@YAHXZ" C#函式宣告寫成: [DllImport("a.dll",EntryPoint="?F@@YAHXZ")]
Time of Update: 2018-12-06
在EXCEL中,輸入超過11位元字時,會自動轉為科學計數的方式,比如:123456789012345,輸入後就變成了:1.23457E14,Excle裡可以更改此列的格式為文本。或者添加" ' " ,即 '123456789012345 。先輸入一個英文單引號“'”,再輸入數值。那麼Excel就認為是文本了,而不會強制變為科學計數法。 用c#的OLEDB匯入Excel到資料庫產生科學計數法問題解決 。 發現Excel的列中只要數字字元較長時oledb讀出的記錄資料會以科學計數法顯示。450
Time of Update: 2018-12-06
byte[] BytePara = 為從C++裡取出的位元組數組;InfoDataStruct 為結構,迴圈將Byte數組裡的內容轉換為結構 InfoDataStruct* p = (InfoDataStruct*)(BytePara+ (i * 55)); InfoDataStruct dataStruct= BytesToStruct<InfoDataStruct>(BytePara, (i * 55)); ///不使用泛型,會使得編碼繁瑣。
Time of Update: 2018-12-06
遍曆獲得一個實體類的所有屬性名稱,以及該類的所有屬性的值//先定義一個類:public class User { public string name { get; set; } public string gender { get; set; } public string age { get; set; } } //執行個體化類,並給實列化對像的屬性賦值:User u = new User(); u.name = "ahbool"; u.gender =
Time of Update: 2018-12-06
//擷取名為"MyClass"的類型 Type t = Type.GetType("MyClass"); //擷取"MyClass"的屬性 PropertyInfo[] properts = t.GetProperties(); //根據屬性名稱擷取某一屬性 PropertyInfo p = t.GetProperty("Id"); //設定某一屬性的值 MyClass my = new MyClass(
Time of Update: 2018-12-06
問題:VS寫類方法屬性注釋時,在同一個工程中注釋可見,跨工程不可見。格式是標準的XML注釋: /// <summary> /// 摘要 /// </summary> /// <param name="param">參數</param> /// <returns>傳回值</returns> 解決方案:在項目屬性中的“產生”選項卡勾選“XML文檔檔案”選項,這樣編譯時間就會在相應目錄下生
Time of Update: 2018-12-06
C#利用反射,遍曆獲得一個類的所有屬性名稱,以及該類的執行個體的所有屬性的值總結:對應某個類的執行個體化的對象tc, 遍曆擷取所有屬性(子成員)的方法(採用反射):Type t = tc.GetType();//獲得該類的Type //再用Type.GetProperties獲得PropertyInfo[],然後就可以用foreach 遍曆了foreach (PropertyInfo pi in t.GetProperties()){ object value1 =
Time of Update: 2018-12-06
C語言概述C語言的發展過程C語言是在 70 年代初問世的。一九七八年由美國電話電報公司(AT&T)貝爾實驗室正式發表了C語言。同時由B.W.Kernighan和D.M.Ritchit合著了著名的“THE C PROGRAMMING LANGUAGE”一書。通常簡稱為《K&R》,也有人稱之為《K&R》標準。但是,在《K&R》中並沒有定義一個完整的標準C 語言,後來由美國國家標準協會(American National Standards
Time of Update: 2018-12-06
指標是C語言中的一個重要的概念,也是C語言的一個重要的特色。正確而靈活地運用它,可以有效地表示複雜的資料結構;能動態分配記憶體;能方便地使用字串;有效而方便地使用數組...掌握指標的應用,可以使程式簡潔、緊湊、高效。可以說,不掌握指標就是沒有掌握C的精華。記憶體區的每一個位元組都有一個編號,這就是“地址”。如果在程式中定義了一個變數,在程式進行編譯時間,系統就會給這個變數分配記憶體單元。在C語言中,對變數的訪問有兩種方式,直接存取和間接訪問。在C語言中,指標是一種特殊的變數,它是存放地址的。
Time of Update: 2018-12-06
今天有時間戳記轉換的需求,網上找了半天才找到相關代碼,經測試有效,特作此筆記和大家分享!1.時間戳記轉為C#格式時間 /// <summary> /// 時間戳記轉為C#格式時間 /// </summary> /// <param name="timeStamp">Unix時間戳記格式</param> ///
Time of Update: 2018-12-06
private void loadtree() { GTree.Nodes.Clear(); ds = workdo.GetDataSet(); InitTree(GTree.Nodes, "0"); } private void InitTree(TreeNodeCollection Nds, string parentid) { DataView
Time of Update: 2018-12-06
ASP.net前台綁定用的最多,今天小小總結一下。1:<%#Eval("")%>2:<%#Bind("")%>3:<%=變數%> 1:<%#Eval("資料列")%> 主要用於需要變更的資料列如:我需要將<%#Eval("性別")%> =1 ;將1轉換成女。首先在.CS檔案中定義一個方法: /// <summary> /// 轉換性別 /// </summary>