How can I convert an array of enums into a generic array of enums in c#.
To be clear:
Given:
public enum PrimaryColor
{
red = 0,
blue = 1,
yellow = 3
}
public enum SecondaryColor
{
green = 0,
purple = 1,
orange = 2
}
I want to do something like this:
public class MyClass
{
public static void Main()
{
PrimaryColor[] pca = {PrimaryColor.blue, PrimaryColor.yellow};
SecondaryColor[] sca = {SecondaryColor.purple, SecondaryColor.orange};
Enum[] enumArray = pca;
}
}
which leads to a compiler error of:
Cannot implicitly convert type 'PrimaryColor[]' to 'System.Enum[]'
I could use linq or some more iterative process, but I wonder if there is a better cast I could use instead.