Guest User

Untitled

a guest
May 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. DateTime.Tomorrow();
  2.  
  3. static DateTime Tomorrow(this Datetime value) { //... }
  4.  
  5. public static MyClass {
  6. public static Tomorrow() { //... }
  7. }
  8.  
  9. static class DateTimeHelper
  10. {
  11. public static DateTime Tomorrow
  12. {
  13. get { return DateTime.Now.AddDays(1); }
  14. }
  15. }
  16.  
  17. DateTime tomorrow = DateTimeHelper.Tomorrow;
  18.  
  19. namespace ExtensionMethods
  20. {
  21. public static class MyExtensionMethods
  22. {
  23. public static DateTime Tomorrow(this DateTime date)
  24. {
  25. return date.AddDays(1);
  26. }
  27. }
  28. }
  29.  
  30. DateTime.Now.Tomorrow();
  31.  
  32. or (any object of type DateTime).Tomorrow();
  33.  
  34. public static class Foo
  35. {
  36. public static void Bar()
  37. {
  38. var now = DateTime.Now;
  39. var tomorrow = typeof(DateTime).Tomorrow();
  40. }
  41.  
  42. public static DateTime Tomorrow(this System.Type type)
  43. {
  44. if (type == typeof(DateTime)) {
  45. return DateTime.Now.AddDays(1);
  46. } else {
  47. throw new InvalidOperationException();
  48. }
  49. }
  50. }
  51.  
  52. public static class DateTimeUtils
  53. {
  54. public static DateTime Tomorrow { get { ... } }
  55. }
  56.  
  57. WriteLine("{0}", DateTimeUtils.Tomorrow)
  58.  
  59. DateTime.Tomorrow
  60.  
  61. DateTimeUtil.Tomorrow
Add Comment
Please, Sign In to add comment