コンストラクタはconstructor[構築子]といって、クラスのインスタンスが生成されるときに実行されるメソッドです。
デストラクタはdestructor[消去子]といって、クラスのインスタンスが消去されるときに実行されるメソッドです。
class Exam {
function __construct() {
}
function __destruct() {
}
}
class Exam {
function Exam() {
}
function ~Exam() {
}
}
Swiftの場合、イニシャライザ・デイニシャライザ
class Exam {
init() {
}
deinit {
}
}
0x0C=12=1100
0x06=6=0110
1100 ^ 0110 = 1010 = 10 = 0x0A
1100 xor 0110 = 1010 = 10 = 0x0A
バックグラウンドで処理を実行中、メインスレッドのメソッドを実行したいとき、
通常のようには呼び出せないので、デリゲートを使って呼び出します。
メインスレッド
Thread tMain = new Thread(new ThreadStart(SampleThread)); tMain.IsBackground = true; tMain.Start();
デリゲートの定義
delegate void SampleDelegate(string args);
メソッドの定義
private void SampleMethod(string args)
{
Console.Writeline(args);
}
スレッド
private void StartServer()
{
this.Invoke(new SampleDelegate(this.SampleMethod), "sample text");
}