Last active
August 29, 2015 14:15
-
-
Save trapezoid/9ef045606b6d8d7068e5 to your computer and use it in GitHub Desktop.
constructor having Enum default value with generics, cause error
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
public enum SampleEnum | |
{ | |
None, | |
Hoge, | |
Huga, | |
Hiyo | |
} | |
public class ConstructorHasEnumDefaultValue<T> | |
{ | |
public SampleEnum Flag { get; private set; } | |
public T Value { get; private set; } | |
public ConstructorHasEnumDefaultValue(T value, SampleEnum e = SampleEnum.None) | |
{ | |
//Error: The name `Value' does not exist in the current context | |
Value = value; | |
//Error: The name `Flag' does not exist in the current context | |
Flag = e; | |
} | |
} | |
public class ConstructorHasEnumDefaultValue | |
{ | |
public SampleEnum Flag {get; private set;} | |
public int Value { get; private set; } | |
public ConstructorHasEnumDefaultValue(int value, SampleEnum e = SampleEnum.None) | |
{ | |
//OK. | |
Value = value; | |
//OK. | |
Flag = e; | |
} | |
} | |
public class ConstructorHasEnumDefaultValueWithSpecificNamespace<T> | |
{ | |
public global::SampleEnum Flag { get; private set; } | |
public T Value { get; private set; } | |
public ConstructorHasEnumDefaultValueWithSpecificNamespace(T value, global::SampleEnum e = global::SampleEnum.None) | |
{ | |
//OK. | |
Value = value; | |
//OK. | |
Flag = e; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment