Basically, if I declare an enum in C#, what interfaces does it implement by default?
public enum Group
{
Unknown,
Children,
Teens,
YoungAdults,
Adults,
}
Why not find out with a simple program?
foreach(var interfaceType in typeof(Group).GetInterfaces())
{
Console.WriteLine(interfaceType);
}
Output:
System.IComparable
System.IFormattable
System.IConvertible
FYI, all of these come from the enum base type System.Enum, which has the following declaration according to MSDN:
[SerializableAttribute]
[ComVisibleAttribute(true)]
public abstract class Enum : ValueType,
IComparable, IFormattable, IConvertible
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With