Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class StringExtensions
- {
- public static OrThat(this string left, string right, string def = string.empty)
- {
- if (!string.IsNullOrEmpty(left))
- return left;
- if (!string.IsNullOrEmpty(right))
- return right;
- return def;
- }
- }
- static main() {
- string left = null;
- string right = "hello";
- var wantedValue = left.OrThat(right);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement