Use this (encapsulate variables to new class as needed):
class Program
{
enum colours_a { red, green, blue, brown, pink }
enum colours_b { yellow, red, blue, green }
static int?[] map_a_to_b = null;
static void Main(string[] args)
{
map_a_to_b = new int?[ Enum.GetValues(typeof(colours_a)).Length ];
foreach (string eachA in Enum.GetNames(typeof(colours_a)))
{
bool existInB = Enum.GetNames(typeof(colours_b))
.Any(eachB => eachB == eachA);
if (existInB)
{
map_a_to_b
[
(int)(colours_a)
Enum.Parse(typeof(colours_a), eachA.ToString())
]
=
(int)(colours_b)
Enum.Parse(typeof(colours_b), eachA.ToString());
}
}
colours_a a = colours_a.red;
colours_b b = (colours_b) map_a_to_b[(int)a];
Console.WriteLine("Color B: {0}", b); // output red
colours_a c = colours_a.green;
colours_b d = (colours_b)map_a_to_b[(int)c];
Console.WriteLine("Color D: {0}", d); // output green
Console.ReadLine();
colours_a e = colours_a.pink;
// fail fast if e's color don't exist in b, cannot cast null to value type
colours_b f = (colours_b)map_a_to_b[(int)e];
Console.WriteLine("Color F: {0}", f);
Console.ReadLine();
}// Main
}//Program