這篇文章講C中static的用法,感覺很經典,轉自http://www.cnblogs.com/dc10101/archive/2007/08/22/865556.html在C語言中,static的字面意思很容易把我們匯入歧途,其實它的作用有三條。(1)先來介紹它的第一條也是最重要的一條:隱藏。當我們同時編譯多個檔案時,所有未加static首碼的全域變數和函數都具有全域可見度。為理解這句話,我舉例來說明。我們要同時編譯兩個源檔案,一個是a.c,另一個是main.c。下面是a.c的內容char a
1 隱式轉換。 2.顯式轉換。使用顯式類型轉換時﹐有一些限制﹕例如數值類型﹐只能在數字﹐char類型﹐enum類型之間轉換 ,不能直接把bool類型轉換成其他類型。強制轉換一個對象的類型,該對象必須與該類型相compatible,即使該對象是在一個object變數裡 但Convert則不見得,它會根據當前參數裡的類型/對象,做解析(parse)或資料轉換,譬如下面能成功 int i = Convert.ToInt32("123");
範例一:運行結果:長等於20,寬等於10的長方形的面積等於:-->200運用重載關係運算子++將長方形面積加10後的長方形面積等於-->210運用重載關係運算子--將長方形面積減10後的長方形面積等於-->200Press any key to continue using System;namespace ConsoleApplication1{ /// <summary> /// Class1 的摘要說明。 ///
'&'和'*' (C++)的區別文章作者:PreludeIt depends on what is meant by &. Since C++ makes use of overloaded built in operators, & can either take the address of an object, perform a bitwise AND operation, do anything related to a user defined type
C#中事件允許一個對象將發生的事件通知其他對象,將發生的事件的事件來源叫發行者,通知其他的對象叫訂閱者,但是訂閱者可以定義也可以不定義(事件發生者也可以是時間的訂閱者)定義事件的步驟:1.定義事件(event關鍵字)2.訂閱事件3.觸發事件下面是一個執行個體的應用using System;using System.Collections.Generic;using System.Text;namespace Person{ class User { ///
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace DelegateText{ class TextDelegate { //定義委託 public delegate void DelegateLogin(string name, string password); //定義事件 public