Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created March 7, 2015 08:19
Show Gist options
  • Save ufcpp/0cd244d7db6b6379b0d1 to your computer and use it in GitHub Desktop.
Save ufcpp/0cd244d7db6b6379b0d1 to your computer and use it in GitHub Desktop.
using static for enum: name conflict
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