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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      66 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      36 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      59 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X