1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
|
|
|
|
|
|
|
|
!
-
|
|
-
|
|
|
|
|
!
|
|
|
-
|
|
|
|
|
!
!
|
.assembly test{}
.method static void Main()
{
.entrypoint
newobj instance void Cart::.ctor() pop
ret
}
.class Cart
{
.method public void .ctor()
{
ldstr "コンストラクタ"
call void [mscorlib]System.Console::WriteLine( string )
ret
}
.method public static void .cctor()
{
ldstr "静的コンストラクタ"
call void [mscorlib]System.Console::WriteLine( string )
ret
}
}
|
実行結果:
静的コンストラクタ
コンストラクタ
C#では・・・
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
-
|
!
-
|
-
|
!
|
|
-
|
!
!
|
void main()
{
new Cart();
}
class Cart
{
public Cart()
{
System.Console.WriteLine("コンストラクタ");
}
static Cart()
{
System.Console.WriteLine("静的コンストラクタ");
}
}
|
VB.NETでは・・・
1
2
3
4
5
6
7
8
9
10
11
12
13
|
Sub Main()
New Cart
End Sub
Class Cart
Public Sub New()
System.Console.WriteLine "コンストラクタ"
End Sub
Shared Sub New()
System.Console.WriteLine "静的コンストラクタ"
End Sub
End Class
|
|
Last-modified: Mon, 27 Jul 2009 03:06:21 JST