Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Int vs. Bool

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Int vs. Bool

    I'm new to C# programming. I am in possession of some third party software and am thinking of modifying it a bit. The original coder has various flags in the code - simple on/off flags - but he/she has them typed as "int". Is there any valid reason in a C# environment to NOT have these be boolean? Does C# process "int" faster than "bool" or something? The only use of these vars in the code is as "true/false" flags.

    Thanks in advance.

    #2
    Hi Weston, typically true/false flags are boolean. I can't imagine there is a huge speed difference between the two, other than the ints taking a little bit more memory space than a bool.

    I'd recommend contacting the author to see if there is a specific reason s/he used ints, and if there isn't, just go ahead and switch them to bool and see if the is a difference.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by Weston View Post
      I'm new to C# programming. I am in possession of some third party software and am thinking of modifying it a bit. The original coder has various flags in the code - simple on/off flags - but he/she has them typed as "int". Is there any valid reason in a C# environment to NOT have these be boolean? Does C# process "int" faster than "bool" or something? The only use of these vars in the code is as "true/false" flags.

      Thanks in advance.
      It might be simply for optimization purposes

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, Yesterday, 10:06 AM
      0 responses
      20 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      18 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      14 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      9 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      38 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X