The Magic of a Single Integer Number to Contain Huge Information

About Sukesh Chand

Sukesh Chand is a Software Project Manager at Bridge Global with more than 15 years of experience in Design and Development of application software & project management. Technical specialist in Microsoft .NET stack, databases, integration architecture and R&D.

5 thoughts on “The Magic of a Single Integer Number to Contain Huge Information
  1. There’s an easier and more readable way in C# to do this using enums & flags.

    [Flags]
    public enum Role
    {
    Anon = 1,
    Admin = 2,
    SuperAdmin = 4
    }

    bool roles = Role.SuperAdmin | Role.Admin;
    bool isSuperAdmin = roles.HasFlag(Role.SuperAdmin);

  2. This is cool! I found I had to change the suggested code from this:
    bool roles = Role.SuperAdmin | Role.Admin;

    to this:
    var roles = Role.SuperAdmin | Role.Admin;

Leave a Reply

Your email address will not be published.