How to set objects name if I only have the number of enum

How to set objects name if I only have the number of enum!

See in code what I meanm Im bad to explain

//Working //Not Working

Code

public enum CarColor
{
    Red = 0,
    Blue= 1,     
}

public class CarColor
{
    public virtual CarColor Id { get; set; }
}

public class Car
{       
    public virtual int Customnumber{ get; set; }
    public virtual CarColor CarColorNumber{ get; set; }       
}


Public SaveIt(Car car)
{
  car.CarColorNumber= CarColor.Blue;  //Working
  car.CarColorNumber= 1;  // not Workingm the color for blue
}
Jon Skeet
people
quotationmark

The supposedly problematic line already works:

// This compiles fine
car.CarColorNumber = 0;

It wouldn't compile for any integer value other than a constant of 0, however. There's an implicit conversion from a constant value of 0 to any enum type, but for anything else it's an explicit conversion. So for example:

int number = 0;
// number is a variable, not a constant expression, so you need to cast.
car.CarColorNumber = (CarColor) number;

people

See more on this question at Stackoverflow