code_junkie

Partial Classes in C#

Nov 11th, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. // Main Part
  2. public partial class Class1
  3. {
  4. private partial void LogSomethingDebugOnly();
  5.  
  6. public void SomeMethod()
  7. {
  8. LogSomethingDebugOnly();
  9. // do the real work
  10. }
  11. }
  12.  
  13. // Debug Part - probably in a different file
  14. public partial class Class1
  15. {
  16.  
  17. #if DEBUG
  18.  
  19. private partial void LogSomethingDebugOnly()
  20. {
  21. // Do the logging or diagnostic work
  22. }
  23.  
  24. #endif
  25. }
Add Comment
Please, Sign In to add comment