Maybe you can tell us what you want to achive by this. But chances are high you need something like this:
System.BitConverter.GetBytes(enumX.y);
this functions has some overloads and should give you the single bytes for the common value types (your enum is based on an integer, if you didn't specify another base type the default is int32).
Does this help?
So what you want is to convert the enum values to single digits, and store them into the Byte array? I found a way by converting to a string and parse it as Bytes. maybe you like it?
using System;
namespace EnumValueToDigits
{
class Program
{
public enum SomeEnum
{
Y = 1011,
Z = 1001
}
static void Main(string[] args)
{
SomeEnum z = SomeEnum.Z;
byte[] abyZ = EnumDigitsToByteArray(z);
foreach (byte by in abyZ)
Console.Write(by);
Console.ReadKey(false);
}
static byte[] EnumDigitsToByteArray(SomeEnum e)
{
string strEnumValue = ((int) e).ToString();
byte[] abyDigits = new byte[strEnumValue.Length];
for (int i = 0; i < strEnumValue.Length; i++)
{
abyDigits[i] = byte.Parse(strEnumValue[i].ToString());
}
return abyDigits;
}
}
}