MSDN原文如是說:Evaluates an expression and, when the result is false, prints a diagnostic message and aborts the program.(判斷一個運算式,如果結果為假,輸出診斷訊息並中止程式。)void assert( int expression );參數:Expression (including pointers) that evaluates to nonzero or
1、建立List用於存放多條語句/// <summary>/// 儲存表單/// </summary>/// <param name="context"></param>protected void save(){ List<string> list = new List<string>(); list.Add(string.Format("insert into
checked 關鍵字用於對整型算術運算和轉換顯式啟用溢出檢查。預設情況下,如果運算式僅包含常數值,且產生的值在目標類型範圍之外,則它會導致編譯器錯誤。 如果運算式包含一個或多個非常數值,則編譯器不檢測溢出。 在下面的樣本中,計算賦給 i2 的運算式不會導致編譯器錯誤。// The following example causes compiler error CS0220 because 2147483647 // is the maximum value for integers.
堆棧(Stack)代表了一個後進先出的對象集合。using System;using System.Collections; namespace CollectionsApplication{ class Program { static void Main(string[] args) { Stack st = new Stack(); st.Push('A');
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace 對象初始化器{ class Program { static void Main(string[] args) { //第二種初始化 var s1 = new student("張三",23);
C#定位字元過濾處理方法,動態替換字串裡面的定位字元。/// <summary>/// Descrioption:///需要替換字元集合,可參見MSDN/// The Trim method only trims 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x0085, 0x2028, and 0x2029./// This array adds in control characters./// Author : 付義方///
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace ConsoleApplication1{ class Program { static void Main(string[] args) { GenericArray<int> intArray = new GenericArray<