Guest User

Untitled

a guest
Jul 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. private static readonly SingletonClass instance = new SingletonClass();
  2. public static SingletonClass Instance
  3. {
  4. get
  5. {
  6. return instance;
  7. }
  8. }
  9.  
  10. private static SingletonClass instance;
  11. public static GetInstance
  12. {
  13. get
  14. {
  15. if(instance == null)
  16. {
  17. instance = new SingletonClass();
  18. }
  19. return instance;
  20. }
  21. }
  22.  
  23. public class MyClass
  24. {
  25. private DataTable _dt;
  26. public DataTable GetDt
  27. {
  28. get
  29. {
  30. if (_dt == null)
  31. {
  32. _dt = new DataTable();
  33. _dt.Columns.Add("Column1", typeof(string));
  34. _dt.Columns.Add("Column2", typeof(string));
  35. _dt.Rows.Add(new string[] { "cell1", "cell2" });
  36. }
  37. return _dt;
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment