title: Wondering why pointer arithmetic not working in asp.net
body: <p>I wanted to try pointer arithmetic in c#. I have used an asp.net web app, expecting that it wouldn't matter if it was this or a console app.</p>
  
  <p>here is what I tried:</p>
  
  <pre><code>public class memorytest
  {
      public class Sample
      {
          public int A;
          public int B;
          public int C;
          public int D;
      }
  
     public static unsafe void Main()
     {
      Sample s = new Sample {A = 1, B = 2, C = 3, D = 4};
      int a = 1;
      int b = 2;
      int* pA = &amp;a;
      int* pB = &amp;b;
      Debug.WriteLine("{0:x16}",* pB);
      Debug.WriteLine("{0:x16}",*(pB - 1));
      Debug.WriteLine(*pA);
      Debug.WriteLine("{0:x16}",*(pB - 2));
      }
  
  }
  </code></pre>
  
  <p>The result was like this:</p>
  
  <p>0000000000000002,
  0000000004b5ca00,
  1,
  0000000004b5c9fc,</p>
  
  <p>I was obviously expecting the second one to be the number 1. Does anybody understand this?</p>