Time of Update: 2018-12-06
又有一段時間沒有更新了,缺少學習的熱情了。今天貼幾個圖片處理的小技巧,希望對大家有用:(1)如何擷取.gif圖片中的各個幀?(2)如何擷取圖片的縮圖?(3)如何“截取”圖片的指定地區?using System.Drawing;using System.Drawing.Drawing2D;using System.Drawing.Imaging;public class ImageHelper{ /**//// <summary> /// 擷取圖片中的各幀 ///
Time of Update: 2018-12-06
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.CodeDom.Compiler;using System.Reflection;namespace Eval_Demo{ /// <summary> /// 動態求值 /// </summary> public class Evaluator {
Time of Update: 2018-12-06
在程式中怎麼實現事件。要明白事件,首先要知道什麼是委託。在C#中委託允許開發人員將一個對象中的方法傳遞給另一個能調用該方法的類的某個對象。比如:可以將類AC中的一個方法ADD[前提是這個方法以被包含在某個委託中了]傳遞給另一個類WMS。此時類WMS就能調用類AC中的ADD了。當然不管你是以什麼方式實現方法的傳遞了,可以是靜態,也可以是執行個體化的。。要實現一個委託,需要按照這樣的不揍:A:申明委派物件。注意:參數一定要和你想要包含的方法的參數形式一致。public delegate void
Time of Update: 2018-12-06
1. 使用建構函式class Form1:Form { public Form1() { Form2 f = new Form2("我要傳給你"); f.Show(); } } public Form2:Form { public Form2() {} public Form2(string title):this() { MessageBox.Show(title); } }2. 使用靜態變數3. 使用委託1 public delegate void
Time of Update: 2018-12-06
Visual C# 語言概念資料類型(C# 與 Java)本主題討論 Java 和 C# 在資料的表示、分配和記憶體回收等方面的一些主要相同點和不同點。複合資料型別在 Java 和 C# 中,類作為有欄位、方法和事件的複合資料型別這一概念是相似的。(有關類繼承的概念在名為繼承與衍生類別(C# 與 Java)的主題中單獨討論。)C#
Time of Update: 2018-12-06
private void Button13_Click(object sender, System.EventArgs e) { this.Datagrid4.Visible=true; Response.Clear(); Response.Buffer= true; Response.Charset="GB2312"; Response.AppendHeader("Content-Disposition","attachment;filename=File1.DOC");
Time of Update: 2018-12-06
委託是一種引用方法的類型。委託定義出它想要代表的方法的原型,然後它可以和任何符合它所定義的方法的原型相關聯。但使用委託時就猶如你在調用一個方法。委託使你動態調用方法變成可能。而動態調用方法的意義就在於你可以在任意的地方插入任意的代碼//=========================================================================================using System;using
Time of Update: 2018-12-06
從資料庫中讀取:方法一:SqlCommand Cmd = new SqlCommand("SELECT * FROM student", MyCn);SqlDataAdapter da = new SqlDataAdapter(Cmd);DataSet ds = new DataSet();da.Fill(ds, "student");Byte[] byteBLOBData = new Byte[0];byteBLOBData =
Time of Update: 2018-12-06
/// <summary> /// 將整個檔案夾複製到目標檔案夾中。 /// </summary> /// <param name="srcPath">源檔案夾</param> /// <param name="aimPath">目標檔案夾</param> public static void CopyDir(string srcPath,string aimPath) { try { //
Time of Update: 2018-12-06
1、DateTime 數字型System.DateTime currentTime=new System.DateTime( );1.1 取當前年月日時分秒currentTime=System.DateTime.Now;1.2 取當前年int 年=currentTime.Year;1.3 取當前月int 月=currentTime.Month;1.4 取當前日int 日=currentTime.Day;1.5 取當前時int 時=currentTime.Hour;1.6 取當前分int
Time of Update: 2018-12-06
在C#.net中操作XML //==================================================================================在C#.net中如何操作XML需要添加的命名空間:using System.Xml;定義幾個公用對象:XmlDocument xmldoc ;XmlNode xmlnode ;XmlElement xmlelem ;1,建立到伺服器同名目錄下的xml檔案:方法一:xmldoc = new
Time of Update: 2018-12-06
using System;using System.Collections.Generic;using System.Text;namespace TestConsole{ // 定義一個委託,用來表示老鼠監聽著貓的動靜 public delegate void CatListeningHandler(); public class Cat { //定義一個事件,這個事件表示貓叫了 public event CatListeningHandle
Time of Update: 2018-12-06
ASPX:<%@ Page %><HTML> <Title>使用全網站計數器</Title> <!--#Include file="GlobCount.inc"--> <script language="c#" runat="server">private void Page_Load(object sender, System.EventArgs e){ if(!IsPostBack)
Time of Update: 2018-12-06
1.checked 和unchecked 是否檢驗溢出查詢。 2.is運算子 檢查對象是否和特定對象相容。if(i is Object){...}3.as運算子用於參考型別顯式類型轉換。 object o1="something"; object o2 = 5; string s1=o1 as string ;// s1 = something; string s2 = o1 as string ;//s2 =null;4.sizeof可以確定棧中實值型別需要的長度(單位位元組)
Time of Update: 2018-12-06
using System;using System.IO;using System.Diagnostics;public static bool Ping(string remoteHost) { bool Flag = false; Process proc = new Process(); try { proc.StartInfo.FileName = "cmd.exe"; proc.StartInfo.UseShellExecute =
Time of Update: 2018-12-06
樣本程式是同步通訊端程式,功能很簡單,只是用戶端發給伺服器一條資訊,伺服器向用戶端返回一條資訊;這裡只是一個簡單的樣本,是一個最基本的socket編程流程,在接下來的文章中,會依次記錄通訊端的同步和非同步,以及它們的區別。 下面是樣本程式的簡單步驟說明伺服器端:第一步:用指定的連接埠號碼和伺服器的ip建立一個EndPoint對像;第二步:建立一個Socket對像;第三步:用socket對像的Bind()方法綁定EndPoint;第四步:用socket對像的Listen()方法開始監聽;第五步:接
Time of Update: 2018-12-06
MessageBox.Show(Convert.ToString(12345, 2)); //10進位轉換為2進位 MessageBox.Show(Convert.ToString(12345, 8)); //10進位轉換為8進位 MessageBox.Show(Convert.ToString(12345, 16)); //10進位轉換為16進位 MessageBox.Show(Convert.ToInt32("1100", 2).ToString());//2進位轉為10進位 Mes
Time of Update: 2018-12-06
本文介紹了什麼是Attribute,Attribute的概念定義,Attribute與Property的區別。一.什麼是Attribute先看下面的三段代碼:1.自訂Attribute類:VersionAttribute[AttributeUsage(AttributeTargets.Class)] public class VersionAttribute : Attribute { public string Name { get; set; }
Time of Update: 2018-12-06
本文介紹C#位元運算的處理方法,第一步, 先建立一個枚舉表示所有的許可權管理操作,接下來是許可權的運算等。 常用的位元運算主要有與(&), 或(|)和非(~), 比如: 1 & 0 = 0, 1 | 0 = 1, ~1 = 0 在設計許可權時, 我們可以把許可權管理操作轉換為C#位元運算來處理. 第一步, 先建立一個枚舉表示所有的許可權管理操作: [Flags] public enum Permissions { Insert = 1, Delete = 2,
Time of Update: 2018-12-06
Console.WriteLine(Evaluator.Eval("1+2+3+4+5+6+7+8+9"));//45Console.WriteLine(Evaluator.Eval("(1+1)/2*3"));Console.WriteLine(Evaluator.Eval("((10-2)/2+1)*3"));//15 using System;using System.Collections.Generic;using System.Linq;using System.Text;using