title: instantiating an object from a web service vs instantiating an object from a regular class
body: <p>I have a very basic web service: </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Services;
  
  namespace WebService1
  {        
      /// &lt;summary&gt;
      /// Summary description for Service1
      /// &lt;/summary&gt;
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      // [System.Web.Script.Services.ScriptService]
      public class Service1 : System.Web.Services.WebService
      {
  
          public int myInt = 0;
  
          [WebMethod]
          public int increaseCounter()
          {
              myInt++;
              return myInt;
          }
  
          [WebMethod]
          public string HelloWorld()
          {
              return "Hello World";
          }
  
      }
  }
  </code></pre>
  
  <p>when I run that project my browser opens showing me the service:
  <img src="https://i.stack.imgur.com/XSli6.png" alt="enter image description here"></p>
  
  <hr>
  
  <h2>on a different solution: (console application)</h2>
  
  <p>I am able to connect to that service by adding the reference:</p>
  
  <p><img src="https://i.stack.imgur.com/Hcaaf.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/6diSb.png" alt="enter image description here"></p>
  
  <p>then click on the add web reference button:
  <img src="https://i.stack.imgur.com/i1Efy.png" alt="enter image description here"></p>
  
  <p>Lastly I type the url of the service I just created:
  <img src="https://i.stack.imgur.com/hUxWH.png" alt="enter image description here"></p>
  
  <p>Now I am able to instantiate an object from the class Service1 from my console application as:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace ConsoleApplication36
  {
      class Program
      {
          static void Main(string[] args)
          {
              localhost.Service1 service = new localhost.Service1();
  
              // here is the part I don't understand..
              // from a regular class you will expect myInt to increase every time you call
              // the increseCounter method. Even if I call it twice I always get the same result.
  
              int i;
              i=service.increaseCounter();
              i=service.increaseCounter();
  
  
              Console.WriteLine(service.increaseCounter().ToString());
              Console.Read();
  
  
          }
      }
  }
  </code></pre>
  
  <p>why does myInt does not increase every time I call the increaseCounter method? every time I call that method it returns 1. </p>