title: Why is it always returning me 0?
body: <p>I have a problem, I want to get the value of a variable who is in another class but I always get the value 0. Can you explain me and how to get the correct value please ? And if the code logic is correct too please.</p>
  
  <pre><code>private void btnNext_Click(object sender, EventArgs e)
  {
      List&lt;Branch&gt; listBranchs = new List&lt;Branch&gt;();
     //Adding Branch to listBranchs ...
  
      listBranchs.ForEach(delegate(Branch branch)
      {
          branchInterf.insertBranch(branch,user);
          BranchDAO bdao = new BranchDAO();
          branch.intBranchID = bdao.getBranchID(); //here is the problem, why bdao.getBranchID() return 0 ?
      });
  }
  </code></pre>
  
  <p>BranchDAO class :</p>
  
  <pre><code>class BranchDAO : BranchInterface
  {
      UserManager userManager = new UserDAO();
      int BranchID;
  
      public void insertBranch(Branch branch, User user)
      {
          var db = new AdventureWorksEntities();
          int IDForNewBranch = 1;
          int IDUser = user.intID;
  
          try
          {
              IDForNewBranch = db.tabBranchs.Max(u =&gt; u.intBranchID);
              IDForNewBranch++;
          }    
          catch {
              IDForNewBranch = 1;
          }
  
          try
          {
              //  code...
              this.BranchID = IDForNewBranch; //IDForNewBranch never equals to 0
              //  code...
          }
          catch (Exception eee)
          {
              Console.Write(eee);
          }
      }
  }
  
  
  public int getBranchID()
  {
      return BranchID;
  }
  </code></pre>