Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. public static class StringExtensions
  2. {
  3. public static OrThat(this string left, string right, string def = string.empty)
  4. {
  5. if (!string.IsNullOrEmpty(left))
  6. return left;
  7.  
  8. if (!string.IsNullOrEmpty(right))
  9. return right;
  10.  
  11. return def;
  12. }
  13. }
  14.  
  15. static main() {
  16. string left = null;
  17. string right = "hello";
  18.  
  19. var wantedValue = left.OrThat(right);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement