Skip to main content
4 of 6
added 145 characters in body
Salah Akbari
  • 40k
  • 10
  • 85
  • 115

You can replace your default value with Null and then use null-coalescing operator, inside your method. Something like this:

public static string ToSummaryString<T>(this IEnumerable<T> items, string delimiter = null) { var realDelimiter = delimiter ?? Environment.NewLine; } 

As an alternative, you can also use Method-Overloading, as @Dennis_E also mentioned: write 2 methods; one with the delimiter and one without.

Salah Akbari
  • 40k
  • 10
  • 85
  • 115