Time of Update: 2018-12-07
/// <summary> /// 將文字轉換成圖片 /// </summary> /// <param name="checkCode"></param> /// <returns></returns> private System.Drawing.Bitmap CreateCheckCodeImage(string checkCode)
Time of Update: 2018-12-07
VB.net 如果需要單一實例運行,只要在其屬性中選中一個複選框就OK了,簡單得不能再簡單了。。。在 C# 中,天生不支援單一實例運行,如果想要單一實例,處理起來很複製。簡單點的有 尋找進程資訊、線程同步等。用起來很不爽。在 VS2008 的 MSDN 中,搜尋 “單一實例”,找到了MS官方的實現方法。頁面地址:單一實例檢測樣本ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.chs/wpf_samples/html/c283e8e9-6fb5-494f-9600-826
Time of Update: 2018-12-07
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo(); //設定外部程式名 Info.FileName = "Update.exe"; Info.WorkingDirectory = Application.StartupPath; //聲明一個程式類
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 System.Runtime.InteropServices;using Microsoft.Win32;using
Time of Update: 2018-12-07
/// <summary> /// Converts an image into an icon. /// </summary> /// <param name="img">The image that shall become an icon</param> /// <param name="size">The width and height of the
Time of Update: 2018-12-07
這段時間因項目需要,要實現WinForm下的檔案上傳,個人覺得採用FTP方法太麻煩,還得配置FTP伺服器,要通過防火牆也是一個麻煩。本來打算採用WebClient方法,但是採用這個方法實現後,進度條很短時間後就達到最大值,要等待一段時間才能傳送完畢,要是檔案太大(我這裡測試約100M),會出現錯誤。後來才知道,原來WebClient是在載入完整個檔案到記憶體後才真正開始上傳,怪不得會出現前面的問題了。不得已參考了很多文章,老外的一個文章對我啟發很大(http://blogs.msdn.com/j
Time of Update: 2018-12-07
/// <summary> /// 產生縮圖 /// </summary> /// <param name="sourceImagePath">原圖片路徑(絕對路徑)</param> /// <param name="thumbnailImageWidth">縮圖的寬度(高度與按源圖片比例自動產生)</param> public
Time of Update: 2018-12-07
[Serializable] public class SolidButton : Button, ISerializable { public SolidButton(SerializationInfo info, StreamingContext ctxt) { this.Location = new Point((int)info.GetValue("X", typeof(int)),
Time of Update: 2018-12-07
結構體可以看做是一種自訂的資料類型,它還有一個很重要的特性,就是結構體可以相互嵌套使用,但也是有條件的,結構體可以包含結構體指標,但絕對不能在結構體中包含結構體變數。struct test { char name[10]; float socre; test *next; };//這樣是正確的!struct test { char name[10]; float socre; test next;
Time of Update: 2018-12-07
const string DGVCBCellType = "System.Windows.Forms.DataGridViewComboBoxCell"; const string DGVTBCellType = "System.Windows.Forms.DataGridViewTextBoxCell"; public CDynIngDGV() //建構函式 {
Time of Update: 2018-12-07
通過.Net FrameWork 2.0下提供的“System.Net.Mail”可以輕鬆的實現,本文列舉了3種途徑來發送: 1.通過Localhost; 2.通過普通SMTP; 3.通過SSL的SMTP; 下面一個一個來說: 1.通過LocalHost 1public void SendMailLocalhost() 2 ...{ 3 System.Net.Mail.MailMessage msg = new
Time of Update: 2018-12-07
Hashtable和ArrayList等經常需要深度拷貝,而.Net沒有現成的函數可以調用,public object Clone() { BinaryFormatter Formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone)); MemoryStream stream = new MemoryStream();
Time of Update: 2018-12-07
在多線程或單線程任務中,讓線程帶傳入參數一直是個麻煩的問題,通常有種方法就是以類,對像的變數來傳參數,這種方法理解上很簡單不過在某些場合使用很麻煩,這裡就不介紹了,我們主要介紹一種.NET2.0中新增加的帶參數運行線程的方法,樣本程式如下:ParameterizedThreadStart ParStart = new ParameterizedThreadStart(ThreadMethod); Thread myThread = new Thread(ParStart);
Time of Update: 2018-12-07
C++中類的多態與虛函數的使用類的多態特性是支援物件導向的語言最主要的特性,有過非物件導向語言開發經曆的人,通常對這一章節的內容會覺得不習慣,因為很多人錯誤的認為,支援類的封裝的語言就是支援物件導向的,其實不然,Visual BASIC
Time of Update: 2018-12-07
using System;using System.IO;using System.Text;using System.Security.Cryptography;using System.Web;namespace Test.Com{ /// <summary> /// DESEncryptor 的摘要說明。 /// </summary> public class DESEncryptor { #region 私人成員
Time of Update: 2018-12-07
using System;using System.Collections.Generic;using System.Text;using System.Net; using System.Net.Mail;using System.Net.Mime;namespace WindowsFormsApplication1{ class SendMail { private MailMessage mailMessage; private
Time of Update: 2018-12-07
解碼: 形如BEGIN:VCARDVERSION:2.1N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;[=E5=86=B7=E6=B1=9F]FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:[=E5=86=B7=E6=B1=9F]TEL;CELL:13099999999X-IRMC-LUID:00020000002CEND:VCARD 這樣的檔案 [=E5=86=B7=E6=B1=9F] 如何解碼呢 str =
Time of Update: 2018-12-07
使用C#格式化字串 1 前言 如果你熟悉Microsoft Foundation Classes(MFC)的CString,Windows Template Library(WTL)的CString或者Standard Template Library(STL)的字串類,那麼你對String.Format方法肯定很熟悉。在C#中也經常使用這個方法來格式化字串,比如下面這樣: int x = 16; decimal y = 3.57m; string h = String.Format(
Time of Update: 2018-12-07
區別C#中的兩個屬性(Property和Attribute) 2012-05-10 14:19:21| 分類: 技術類 | 標籤:c# property attribut |字型大小大中小 訂閱區別C#中的兩個屬性(Property和Attribute)
Time of Update: 2018-12-07
GOF的《設計模式》中這樣描述:保證一個類僅有一個執行個體,並提供一個訪問它的全域訪問點。通常我們可以讓一個全域變數使得一個對象被訪問,但它不能阻止你執行個體化多個對象。一個最好的辦法是,讓類自身負責儲存它的唯一執行個體。這個類可以保證沒有其他執行個體可以被建立,並且它可以提供一個訪問該執行個體的方法。也就是說,很多時候我們需要全域的對象,如一個工程中,資料庫訪問對象只有一個,這時,可以考慮使用單例模式。單例模式比全域對象好還包括:單例類可以繼承,如下例。單例模式的關鍵點在於:建構函式私人,靜態