大域変数(グローバル変数 グローバルフィールド)を使ってみます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
-
|
|
|
|
|
|
|
|
|
|
|
|
!
|
.assembly x {}
.field static string str1
.method static void main()
{
.entrypoint
ldstr "deep blue morocco" stsfld str1
ldsfld str1 call void class [mscorlib]System.Console::WriteLine(string)
ret
}
|
実行結果:
deep blue morocco
大域変数の初期化について †
大域変数は自動的に0で初期化されます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-
|
|
|
|
|
|
|
|
|
!
|
.assembly x {}
.field static int32 x
.method static void main()
{
.entrypoint
ldsflda int32 x call instance string class [mscorlib]System.Int32::ToString() call void class [mscorlib]System.Console::WriteLine(string)
ret
}
|
実行結果:
0
stringの場合は""になります。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
-
|
|
|
|
|
|
|
|
!
|
.assembly e{}
.field static string x
.method static void main()
{
.entrypoint
ldsfld string x call void class [mscorlib]System.Console::WriteLine(string)
ret
}
|
実行結果:
参照 †
|
Last-modified: Mon, 27 Jul 2009 03:06:22 JST