Set bit flags


Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Bit-level manipulation is a common practice to conserve space in programs. Eight Yes/No, On/Off bits of data may be stored in a single byte instead of using up 8 bytes. The AccessMask property is an example of this kind.


The following example shows how to turn on or off the specified display flag for an attribute.

//Turn flag on
    _currentAccessRights |= AccessRights.ReadAccess;
//Turn flag off
    _currentAccessRights &= ~AccessRights.ReadAccess;

// Test to see if flag is set
If (_currentAccessRights.HasFlag(AccessRights.ShareAccess))
    // Flag is set.

See Also

Best practices for developing with Microsoft Dynamics 365
Blog: A Quick Bitmask How to for Programmers

Microsoft Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright