Created
March 7, 2015 08:19
-
-
Save ufcpp/0cd244d7db6b6379b0d1 to your computer and use it in GitHub Desktop.
using static for enum: name conflict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using static Color; | |
using static Mood; | |
enum Color { Red, Blue } | |
enum Mood { Cheerful, Blue } | |
class Program | |
{ | |
static void C(Color c) => Console.WriteLine($"color: {c}"); | |
static void M(Mood m) => Console.WriteLine($"mood: {m}"); | |
static void Main(string[] args) | |
{ | |
C(Red); | |
M(Cheerful); | |
C(Blue); // Error CS0229 Ambiguity between 'Color.Blue' and 'Mood.Blue' | |
M(Blue); // Error CS0229 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment