Write the values as shifted bits and let the compiler do the math:
[Flags]
private enum Targets : uint
{
None = 0,
Campaigns = 1,
CampaignGroups = 2 << 0,
Advertisers = 2 << 1,
AdvertiserGroups = 2 << 2,
AffiliateGroups = 2 << 3,
Affiliates = 2 << 4,
Creatives = 2 << 5,
DetailedLeads = 2 << 6,
DetailedSales = 2 << 7,
ProgramLeads = 2 << 8,
CreativeDeployments = 2 << 9,
CampaignCategories = 2 << 10,
Payouts = 2 << 11,
// etc.
}
James's suggestion is a good one, too. In fact I like this way even better. You could also write it like this:
[Flags]
private enum Targets : uint
{
None = 0,
Campaigns = 1 << 0,
CampaignGroups = 1 << 1,
Advertisers = 1 << 2,
AdvertiserGroups = 1 << 3,
AffiliateGroups = 1 << 4,
// etc.
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…