title: How to add integers in different methods
body: <p>I'm very new to C# and have a very limited understanding of the "proper code" to use. I had the goal to imitate the old Pokemon battle systems as best I could with what I know and am having a hard time linking a stored <strong>int</strong> value for <strong>HP</strong> between two methods (assuming that's the right word), to calculate new Hp when the second method interacts with the main method. Had a hard time finding an answer for that in searches so here is the code:</p>
  
  <pre><code>" static void Main(string[] args)
          {
              Random Gen = new Random();
  
              int enemyhealth = (150);
              int playerhealth = (100); //the line i need to use
              int edefense = (20);
              int pattack = (30);
              int rate = Gen.Next(1,5);
              int critical = 0;                   "
  
  
   static void enemyattack()
          {
              Random Gen1 = new Random();
  
              int pdefense = (20);
              int eattack = (20);
              int erate = Gen1.Next(1, 5);
              int ratattack = Gen1.Next(1,3);
              int critical1 = 0;
  
              Console.WriteLine("Enemy Ratta gets ready!");
              Console.ReadKey();
              Console.WriteLine("----------------------------------------------------------------------------");
              Console.WriteLine("\nEnemy Ratta attacks!\n");
              Console.WriteLine("----------------------------------------------------------------------------");
  
              ratattack = Gen1.Next(1,3);
              if (ratattack = 1)
              {
                  Console.WriteLine("Enemy Ratta used Tail Whip!");
                  pdefense = (pdefense - erate);
                  Console.ReadKey();
                  Console.WriteLine("----------------------------------------------------------------------------");
                  erate = Gen1.Next(1, 5);
                  if (erate &lt;= 3)
                  {
                      Console.WriteLine("\nIt wasn't very effective!");
                  }
                  else
                  {
                      Console.WriteLine("\nIt was super effective!");
                  }
                  Console.WriteLine("Squirtle's Defense decreased by " + erate + "");
                  Console.WriteLine("----------------------------------------------------------------------------");
              }
              else if (ratattack == 2)
              {
                  Console.WriteLine("\nRatta used Tackle");
                  erate = Gen1.Next(1, 5);
                  if (erate &gt;= 5)
                  {
                      Console.WriteLine("----------------------------------------------------------------------------");
                      Console.WriteLine("----------------------------------------------------------------------------");
                      Console.WriteLine("\nCRITICAL HIT!!!!");
                      Console.WriteLine("----------------------------------------------------------------------------");
                      Console.WriteLine("----------------------------------------------------------------------------\n");
                      Console.ReadKey();
                      Console.WriteLine("It was super effective!");
                      Console.ReadKey();
                      eattack = eattack + 10;
                  }
                  else
                  {
                      critical1 = Gen1.Next(1, 5);
                      eattack = critical1 + eattack;
                  }
                  phealth = Math.Abs((eattack - pdefense) - playerhealth);    ***//This Line is where I'm having trouble because phealth is used in my first method as a stored integer and the new calculation for phealth won't interact with the phealth in the origional main, i simply belive I haven't learned that part of c#, I only have 5 hours of youtube tutorials.***
                  Console.WriteLine("Ratta dealt " + Math.Abs(eattack - pdefense) + " damage!");
                  eattack = 30;
                  Console.WriteLine("\n----------------------------------------------------------------------------");
                  Console.ReadKey();
  
                  Console.ReadKey();
              }
  
          }
      }
  }
  </code></pre>