title: How do I check if a value type has a value of IntPtr.Zero
body: <p>So I am writing a <code>Xamarin</code> application and I have built a <code>CustomRenderer</code></p>
  
  <p>now my method:</p>
  
  <pre><code>horizontalScrollView.ScrollTo(this.Width, 0);
  </code></pre>
  
  <p>keeps throwing an exception:</p>
  
  <blockquote>
    <p>System.ArgumentException: 'jobject' must not be IntPtr.Zero.
    10-21 12:10:41.898 E/AndroidRuntime(15053): Parameter name: jobject
    10-21 12:10:41.898 E/AndroidRuntime(15053): at Android.Runtime.JNIEnv.CallIntMethod (intptr,intptr) [0x00010] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:378
    10-21 12:10:41.898 E/AndroidRuntime(15053): at Android.Views.View.get_Width ()</p>
  </blockquote>
  
  <p>So looking at the exception and from my breakpoints I find that the problem is that when I hover over <code>this.Width</code> I get <code>'jobject' must not be IntPtr.Zero</code> instead of an <code>integer</code> so I try to defensively code against this and do:</p>
  
  <pre><code>if (this.Width != IntPtr.Zero)
  {
     horizontalScrollView.ScrollTo(this.Width, 0);
  }
  </code></pre>
  
  <p>but this doesnt compile and gives me the error:</p>
  
  <blockquote>
    <p>Operator '!=' cannot be applied to operands of type 'int' and
    'IntPtr'</p>
  </blockquote>
  
  <p>So my questions is. Is there a way to check whether a <code>value type</code> is equal to <code>IntPtr.Zero</code>?</p>