# Coalescing delegates

Did you know the coalesce operator (??) works for delegates? I had never really thought about it, but it does and you can use it to create confusing passages of code like this one… :)

delegate String ConvertToString(LookupEntity entity);
String defaultStringConversion(LookupEntity entity) { return "default"; }

String loadAndDisplay(Guid id, ConvertToString converter) {
return (converter ?? defaultStringConversion)(entity);
}

[Test]

In this contrived example we are using it to provide a default delegate function if none is specified in the call to loadAndDisplay. I’m not necessarily recommending this, I just found it interesting :)