Should this code compile? Does it? What does it mean?
using System;class Test
{
enum Foo { Bar, Baz };
static void Main()
{
Foo f = 0.0;
Console.WriteLine(f);
}
}
Should this code compile? Does it? What does it mean?
using System;}
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Sep 7, 2012, 7:23 PM EDT
Baras that's the 0 value of theFoo.VulpesRank #55 · 29.2K reputationPosted Sep 8, 2012, 3:03 AM EDT
It doesn't even mind 0L, 0U or 0UL despite the fact that the underlying type of the enum is int.
Definitely contrary to the spec and quite shocking!
Thanks for pointing it out :)
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Sep 16, 2012, 9:07 PM EDT