Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bool arithmetic fundamental

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

    bool arithmetic fundamental

    Hi
    Sorry, I have two very simple questions:
    - In the case of a boolean object can I write 0, and 1 or only true and false
    - I have a boolean vector, named vector. I would like to invert it. (All of parts of them) I tried "!vector" but it was not good. What is the right one?

    Lot of thanks

    Akos

    #2
    Hello,

    In C#, booleans are always true or false, not 1 or 0. Can you please clarify what you mean by a boolean vector? Do you mean a boolean variable? If so, you can swap the boolean to its opposite state via "vector = !vector."

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Hello Dave


      I have defined an array with three elements :

      bool[] vector = new bool[]{true,true,true}

      now I want to convert all of the elements to false, so I want to invert the array

      Thank you

      Akos

      Comment


        #4
        I believe a for loop would do the job here. Something like:

        Code:
        for (int i = 0; i < vector.length - 1; i++)
        {
              vector[i] = !vector[i]
        }
        Please let me know if I can assist further.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Hi Dave,
          Thank you for your ansver. I hope that we can make aritmetic with array directly, but it seems not...
          Have a nice day
          Akos

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          142 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          81 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          125 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          120 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          98 views
          0 likes
          Last Post CarlTrading  
          Working...
          X