I recently found an interesting C # compiler behavior. Imagine this interface:
public interface ILogger
{
void Info(string operation, string details = null);
void Info(string operation, object details = null);
}
Now if we do
logger.Info("Create")
The compiler will complain that it does not know which overload to choose (Ambiguous call ...). It seems logical, but when you try to do this:
logger.Info("Create", null)
Suddenly there will be no problem figuring out that null is a string. In addition, it seems that the behavior of finding the correct overload has changed over time, and I found an error in the old code that worked before and stopped working because the compiler decided to use a different overload.
, , # , . , .
P.S. , , :)