I was looking through the source of my NHibernate project (version 3.3.1.4000) and I just noticed something strange in the AnywhereMatchMode class:
public override string ToMatchString(string pattern)
{
return (string) (object) '%' + (object) pattern + (string) (object) '%';
}
Why on earth would they cast a char to an object and immediately re-cast it to a string? Why cast a string to an object before adding it to other strings? Is there a performance bonus here, or an edge case to avoid? I'm looking for the idea behind this code, because there must be a reason for it.
Note: I just realized, I got here with ReSharper's "Navigate To" feature, so this may be decompiled code I'm looking at. Even if it is, I'd like to know what's going on here.