前些日子做一個Web項目,必須自己編寫一個ActiveX控制項。如今的ActiveX控制項大多是使用VB/C++來開發的,而我對他們並不熟悉,因此考慮使用熟悉的C#編寫ActiveX控制項。 首先,建立一個WinForm控制項項目HelloWorld,並拖入一個Label控制項,文字設為HelloWorld, UserControl1.cs內容如下: using System; using System.Collections;
嘗試了一下用C#寫了一下二叉樹的相關演算法: 代碼Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> #region 擷取二叉樹深度 static int z, d = 0; //z用於記錄遍曆到某節點時的深度,d用於記錄最大深度 static int GetTreeDep(TreeNode node)
調用建構函式和解構函式的順序先構造的後析構,後構造的先析構。歸納下什麼時候調用建構函式和解構函式(1) 全域範圍內定義的對象,他的建構函式在檔案中所有函數執行之前執行。但是當程式定義了多個檔案,而不同的檔案中都定義全域變數時候,,則對象的建構函式的調用順序是不確定的,當main函數結束或者運行了exit函數時,調用解構函式(2) 定義的是局部自動對象時,則在建立對象是調用其建構函式。如果函數多次調用,則在每次建立對象是後都要調用建構函式,函數調用結束時調用解構函式(3) Sta
1: using System; 2: using System.Collections.Generic; 3: using System.Linq; 4: using System.Text; 5: using System.Threading; 6: using System.Diagnostics; 7: 8: namespace Semaphore 9: { 10: class Program 11: { 12:
利用c#2.0的範型加上一點反射,構造了一個自認為不錯的Singleton實現. public class Singleton<T> { protected Singleton() { //Assert class T don't have public constructor //Assert class T have a private/protected parameterless constru
AForge.NET is another C# framework to do image processing and others. For further information just go to http://www.aforgenet.com/framework/Here, I want to show you another way to access your webcam using AForge library. I found this library is