KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
protected static new void WhyIsThisValidCode() { } Why are you allowed to override static methods? Nothing but bugs can come from it, it doesn't work as you would think. Take the following classes: class BaseLogger { protected static string LogName { get { return null; } } public static void Log(string message) { Logger.Log(message, LogName); } } class SpecificLogger : BaseLogger { protected static string LogName { get { return "Specific"; } } } This is allowed, and the code SpecificLogger.Log("test"); is also allowed, but it doesn't do what you would think by looking at the code. It calls Logger.Log with LogName = null . So why is this allowed?
Tags (comma-separated)
Save Edits
Cancel