KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
C#3 (Visual Studio 2008) introduced a breaking change to the language ( http://msdn.microsoft.com/en-us/library/cc713578.aspx , see change 12) that allows any literal zero to be implicitly converted to an Enum. This seems odd in many ways. Does anyone know why this is part of the spec? Why not a literal one? Or seven? Why is zero special? And it makes some very counterintuitive overload resolution choices. For instance. function string F(object o) { return o.ToString(); } function string F(DbType t) { return t.ToString(); } int i = 0; F((long)0) == "String" // would have been "0" in VS 2005 F(0) == "String" F(i) == "0" Very confusing, and an intentionally introduced breaking change to the language. Any ideas?
Tags (comma-separated)
Save Edits
Cancel