Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class A {
- public A() { Console.WriteLine("A"); }
- }
- class B {
- public B() { Console.WriteLine("B"); }
- }
- public class Test
- {
- static readonly A a;
- static readonly B b;
- public static void Main()
- {
- }
- static Test()
- {
- b = new B();
- Console.WriteLine("-");
- a = new A();
- }
- }
- public sealed class Singleton
- {
- private static readonly Singleton instance = new Singleton();
- // Explicit static constructor to tell C# compiler
- // not to mark type as beforefieldinit
- static Singleton()
- { }
- private Singleton()
- { }
- public static Singleton Instance { get { return instance; } }
- }
- class Foo
- {
- private string s1 = "s1";
- private string s2;
- private static string s3 = "s3";
- private static string s4;
- public Foo()
- {
- s2 = "s2";
- }
- static Foo()
- {
- s4 = "s4";
- }
- }
- // ctor
- // Код инициализаторов полей
- // Вызов конструктора базового класса
- // Код текущего конструктора
- internal class SomeType {
- private static Int32 s_x = 5;
- }
- internal class SomeType {
- private static Int32 s_x;
- static SomeType() { s_x = 5; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement