Behavior trees(BT) are implemented from their hierarchical, branching system of nodes with a common parent, known as the root. Behavior trees try to mimic the real thing they are named after—in this case, trees, and their branching structure, it would look something like the following figure:
A basic tree structure
Behavior trees can be build up with any number of nodes and child nodes. The nodes at the very end of the hierarchy are referred to as leaf nodes, just like a tree. Nodes can represent behaviors or tests. Unlike the state machines, which rely only on transition rules to traverse through them, BT’s flow is defined strictly by each node’s order within the larger hierarchy. A BT begins evaluating from the top of the tree (based on the preceding visualization), then continues through each child, which, in turn, runs through each of its children until the leaf node is reached. BTs always begin evaluating from the root node.
You can refer the following link for the implementation in C#:https://forum.unity.com/threads/how-to-program-c-behavior-tree.526077/
If you wish to know more about AI Behavior Tree then visit this Artificial Intelligence Course.