Results 1 to 2 of 2

Thread: C# Code Confirmation

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    102

    C# Code Confirmation

    Lo all just wondering if someone could just confirm what this code does. I have my ideas just would like it confirmed.

    Code:
    			int flags = 0x3 | m_AdditionalFlags;
    
    			if ( Core.SE )
    				flags |= 0x0040;
    
    			if ( Core.AOS )
    				flags |= 0x801C;
    
    			if ( acct != null && acct.Limit >= 6 )
    			{
    				flags |= 0x8020;
    				flags &= ~0x004;
    			}
    Does it translate in pseudo as...
    Code:
             Flags = 0x03 or m_AdditionalFlags
             if core.se is true then flags = 0x0040
             if core.aos is true then flags = 0x801c
             if acct is not null and acct.limit is greater or equal to 6 then 
             {
                        flags = 0x8020
                        flags  = flags + 0x004
             }
    am i right in what ive wrote or is it like...

    if core.se is true then flags = flags + 0x0040
    if core.aos is true then flags = flags + 0x801c

    Hope someone can help...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: C# Code Confirmation

    flags |= 0x0040 <=> flags = flags | 0x0040

    i.e. flags is bit-wise ORed with 0x0040. Bit-wise OR means that the result will have any particular bit set, i.e. equal to 1, if and only if that same bit is set in either one or both of the operands. A bit-wise AND will set a bit if and only if that same bit is set in both operands.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width