This documentation is archived and is not being maintained.

Working with Bit Flag Values

Dynamics
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Bit-level manipulation is a common practice to conserve space in programs that want to conserve space. Eight Yes/No, On/Off bits of data may be stored in a single byte rather than using up 8 bytes. The AttributeMetadata class uses a bit flag to store the display mask that determines which forms can display an attribute. Another use is for the access levels in the PrincipalAccess class.

Example

The following sample code shows a method that turns the specified display flag for an attribute on or off.

[C#]
public void SetDisplayMaskFlag(AttributeMetadata attribute, DisplayMasks flag, bool turnFlagOn)

{
       if (turnFlagOn)
       {
              attribute.DisplayMask.Value |= flag;
       }
       else
       {
              attribute.DisplayMask.Value &= ~flag;
       }
}

Example

The following sample code shows a test to see whether the specified display flag for an attribute is set.

[C#]
if ((attribute.DisplayMask.Value &= DisplayMasks.ValidForForm) > 0)
   bFlagValue = true;

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: