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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          152 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          305 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          244 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          345 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          176 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X