Skip to content

Instantly share code, notes, and snippets.

@idusortus
Last active October 10, 2019 16:11
Show Gist options
  • Save idusortus/e09d4dec1bf9f5ea5e83a1b2ab4382fa to your computer and use it in GitHub Desktop.
Save idusortus/e09d4dec1bf9f5ea5e83a1b2ab4382fa to your computer and use it in GitHub Desktop.
// ternary operator
public static string Speak(string name="") => $"One for {(name=="" ? "you" : name)}, one for me.";}
// default value for optional argument
public static string Speak(string name="you") => string.Format("One for {0}, one for me.", name);
// null-coalescing assignment operator
public static string Speak(string name = null) => $"One for { name ?? "you"}, one for me.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment