I am reading "C# via CLR" and on page 380, there's a note saying the following:
Note The Enum class defines a HasFlag method defined as follows
public Boolean HasFlag(Enum flag);Using this method, you could rewrite the call to Console.WriteLine like this:
Console.WriteLine("Is {0} hidden? {1}", file, attributes.HasFlag(FileAttributes.Hidden));However, I recommend that you avoid the HasFlag method for this reason:
Since it takes a parameter of type Enum, any value you pass to it must be boxed, requiring a memory allocation ."
I can not understand this bolded statement -- why "
any value you pass to it must be boxed
The flag parameter type is Enum, which is a value type, why would there be boxing? The "any value you pass to it must be boxed" should mean boxing happens when you pass value type to parameter Enum flag, right?