Finding Object in a List

Forums 💬 FlowCanvas ⚙️ Support Finding Object in a List

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #22363
    ktysdal
    Participant

      Hello,
      I am trying to figure out a simple way to search a list for a specific object, but no matter what I try I can’t seem to come up with an elegant solution.
      After some time on google it seems like using List<T>.Contains Method (https://msdn.microsoft.com/en-us/library/bhkz42b3.aspx) would be the way to do it in C#, but I’m not able to figure out how to access that in flowCanvas :/

      #22366
      Gavalakis
      Keymaster

        Hello,
        You can use List.Contains method in FlowCanvas too.
        Here is a small step-by-step for example:

        1) Create a list variable:
        [attachment file=”MyList.png”]

        2) Drag the variable into the editor canvas and select “Get”, to create a node that gets the variable value.

        3) Drag the “Value” output of that new node into empty canvas. This will pop up a list of everything you can do with that type of value. In this case (List).
        [attachment file=”DragPort.png”]

        Within the List category in that popup you will see a lot of list related methods. One of them is Contains. Click it to create a new node that check if the List contains an element.

        For the shake of this example, I added a few more nodes to showcase something more practical:
        [attachment file=”ListContains.png”]

        Let me know if that is indeed what you were after.
        Thanks!

        #22365
        ktysdal
        Participant

          Oh wow, that was embarrassingly simple 🙂
          Great! That was exactly what I was after. Thank you so much again Gavalakis.

          I think the main reason why I was having a hard time getting this to work was because when you hit spacebar and search for “contains” this specific “List-Contains-Transform” node does not appear. The only thing that shows up in the search was a “Contains” node that works with strings.

          —————
          PS: thank so much for adding the Duplicate and Delete multiple hotkeys in 1.3.2. They are very useful.

          #22364
          Gavalakis
          Keymaster

            Hey,
            You are very welcome!
            I think dragging and dropping a port into empty canvas is the best way to get all nodes that are possible to be performed with that dragged port’s type 🙂

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.