I am a little new to extensions. I looked at the existing answer before posting it, because I do not like to write, but I did not see anything that was useful to me.
I want to have an extension method for an enumeration with the Flag attribute that I can call to basically add another enum / flag to the calling enumeration.
Before someone ran this on Int32.MinValue, I really looked enough, but all I found was a bunch of questions for "IsFlagSo-andSet" and flag handling, but not just adding a flag.
I defined the listing as follows:
[Flags]
internal enum eDiskFormat
{
None = 0x00,
_3D = 0x01,
Blu_ray_3D = 0x02,
Blu_ray = 0x04,
DigitalCopy = 0x08,
Dvd = 0x10
}
The extension has been defined as:
internal static void AddFormat(this Movie.eDiskFormat target, Movie.eDiskFormat newFormat)
{
target |= newFormat;
}
, , Movie.eDiskFormat.Blu_ray... ( eDiskFormat.None).
m.DiskFormat.AddFormat(Movie.eDiskFormat.Blu_ray);
eDiskFormat.None. , "this" , , , , . , , ... , , ; , .