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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      52 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      275 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X