-
Notifications
You must be signed in to change notification settings - Fork 56
/
Program.cs
46 lines (40 loc) · 1.16 KB
/
Program.cs
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
40
41
42
43
44
45
46
using System;
namespace InitializationOrder
{
public class InitializationTestClass
{
public InitializationTestClass()
{
Console.WriteLine("Constructor");
}
static InitializationTestClass()
{
Console.WriteLine("Static constructor");
}
public static int s1 = GetValue("Static field 1");
public int ns1 = GetValue("Non-static field 1");
public static int s2 = GetValue("Static field 2");
public int ns2 = GetValue("Non-static field 2");
private static int GetValue(string message)
{
Console.WriteLine(message);
return 1;
}
public static void Foo()
{
Console.WriteLine("Static method");
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Main");
InitializationTestClass.Foo();
Console.WriteLine("Constructing 1");
InitializationTestClass i = new InitializationTestClass();
Console.WriteLine("Constructing 2");
i = new InitializationTestClass();
}
}
}