Guest User

Untitled

a guest
Jul 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. //Transform:
  2.  
  3. class C
  4. {
  5. public lazy string SomeProperty
  6. {
  7. get
  8. {
  9. return SomeLengthyCalculation();
  10. }
  11. }
  12.  
  13. public C()
  14. {
  15. ...
  16. }
  17. }
  18.  
  19. //To:
  20.  
  21. class C
  22. {
  23. public string SomeProperty
  24. {
  25. get
  26. {
  27. return SomePropertyBackingField.Value
  28. }
  29. }
  30.  
  31. public C()
  32. {
  33. ...
  34. SomePropertyBackingField = new Lazy<string>(SomeLengthyCalculation);
  35. }
  36.  
  37. private readonly Lazy<string> SomePropertyBackingField;
  38. }
Add Comment
Please, Sign In to add comment