Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:04:17+00:00 2026-06-06T06:04:17+00:00

I just learned the hard way that IntPtr.Zero cannot be compared to default(IntPtr). Can

  • 0

I just learned the hard way that IntPtr.Zero cannot be compared to default(IntPtr). Can someone tell me why?

IntPtr.Zero == new IntPtr(0) -> "could not evaluate expression"
IntPtr.Zero == default(IntPtr) --> "could not evaluate expression"
IntPtr.Zero == (IntPtr)0 -> "could not evaluate expression"

IntPtr.Zero.Equals(IntPtr.Zero) --> "Enum value was out of legal range" exception
IntPtr.Zero.Equals(default(IntPtr)) --> "Enum value was out of legal range" exception

IntPtr.Zero == IntPtr.Zero --> true
new IntPtr(0) == new IntPtr(0) --> true
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:04:18+00:00Added an answer on June 6, 2026 at 6:04 am

    Works for me in compiled code in VS 2010, VS 2008, VS 2005 SP1, Mono 1.2.6. Managed to reproduce both problems in the watch window of Visual Studio 2005 only (I tried with VS 2005 SP1), the compiled code works as expected. (By both problems I mean Problem 1: “Could not evaluate expression”, Problem 2: “Enum value was out of legal range”.) Thus, as was pointed out by some of the comment authors, it is a VS 2005 watch window bug that you stumbled upon. It is surprisingly hard to quickly find a link to the relevant bug report…

    Otherwise in such cases I’d start from reflection to see what types you try to compare (replace Console.Out with any meaningful stream you have access to):

    Console.WriteLine("new IntPtr(0) type is: " + new IntPtr(0).GetType());
    Console.WriteLine("IntPtr.Zero type is: " + IntPtr.Zero.GetType());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just learned (the hard way) that Java Component s can only have one
as I learned the hard way, Flash streams your .swf, that is, it can
I've learned the hard way that regexes cannot adequately parse html, prior to finding
I'm new to shell,I just learned that use (command) will create a new subshell
I used to install betas freely and learned the hard way that I best
I just learned of vim's gf command for navigating to files that are referenced
as I've just learned in in my other question , I could use a
As I just learned from this question , .NET regexes can access individual matches
I am a newbie and just learned that if I define say package my.first.group.here;
I just learned that, quoting make a huge difference in some cases, and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.