Guest User

Untitled

a guest
Jan 17th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2.  
  3. class A {
  4. public A() { Console.WriteLine("A"); }
  5. }
  6.  
  7. class B {
  8. public B() { Console.WriteLine("B"); }
  9. }
  10.  
  11. public class Test
  12. {
  13. static readonly A a;
  14. static readonly B b;
  15.  
  16. public static void Main()
  17. {
  18. }
  19.  
  20. static Test()
  21. {
  22. b = new B();
  23. Console.WriteLine("-");
  24. a = new A();
  25. }
  26.  
  27. }
  28.  
  29. public sealed class Singleton
  30. {
  31. private static readonly Singleton instance = new Singleton();
  32.  
  33. // Explicit static constructor to tell C# compiler
  34. // not to mark type as beforefieldinit
  35. static Singleton()
  36. { }
  37.  
  38. private Singleton()
  39. { }
  40.  
  41. public static Singleton Instance { get { return instance; } }
  42. }
  43.  
  44. class Foo
  45. {
  46. private string s1 = "s1";
  47. private string s2;
  48.  
  49. private static string s3 = "s3";
  50. private static string s4;
  51.  
  52. public Foo()
  53. {
  54. s2 = "s2";
  55. }
  56.  
  57. static Foo()
  58. {
  59. s4 = "s4";
  60. }
  61. }
  62.  
  63. // ctor
  64. // Код инициализаторов полей
  65. // Вызов конструктора базового класса
  66. // Код текущего конструктора
  67.  
  68. internal class SomeType {
  69. private static Int32 s_x = 5;
  70. }
  71.  
  72. internal class SomeType {
  73. private static Int32 s_x;
  74. static SomeType() { s_x = 5; }
  75. }
Add Comment
Please, Sign In to add comment