以《資料結構》學習筆記(二)中JavaScript程式碼實現的棧操作執行個體為範例用C#語言編程重寫: Stack s = new Stack();s.Push(1);s.Push(2);s.Push(2);s.Push(2);s.Push(null);object b = s.Pop();Console.WriteLine("s 的Pop方法: " + b);foreach(int j in s){Console.WriteLine("s: " + j);}s.Push(3);foreach(
//DirectoryInfo dir = new DirectoryInfo("c:\\"); // System.IO .FileSystemInfo[] fis = dir.GetFileSystemInfos(); // if (fis[1] is DirectoryInfo ) // { // //fis[1]是一個檔案夾 // } // if
有時候在代碼中不得不寫很長的一句sql語句。那麼怎樣才能換行使看起來很容易呢?最好的辦法是用@符號.而@的意思就是告訴編譯器,這裡面的字元不需要轉義,如下面的sql語句: string SQL = @"select a.numid,a.vc2title, vc2type=case when a.vc2type='1' then '供' when a.vc2type='2' then '求' end ,
using System.Text.RegularExpressions;string ohtml = this.TextBox1.Text; System.Text.RegularExpressions.MatchCollection m; //提取字串的圖片 m = Regex.Matches(ohtml, "(<img).*?>"); for (int i = 0; i <
using System;using System.Runtime.InteropServices;using System.Windows.Forms;using System.Diagnostics;using System.Reflection;namespace OneInstance{ /// <summary> /// Class with program entry point. /// </summary> internal sea
1,本文段。這是由C P U執行的機器指令部分。通常,本文段是可共用的,所以即使執行的程式(如文本編輯程式、C編譯器、s h e l l等)在儲存空間中也只需有一個副本,另外,本文段常常是唯讀,以防止程式由於意外事故而修改其自身的指令。 2,初始化資料區段.通常將此段稱為資料區段,它包含了程式中需賦初值的變數。例如, C程式中任何函數之外的說明:int maxcount = 99;使此變數以初值存放在初始化資料區段中。是不是全域靜態變數? 3,非初始化資料區段。通常將此段稱為b s