NEWBIE: Int32 won't hold nulls
Posted on 2006-04-19
I'm converting my world from Java to C#...
First problem: I regularly put NULL into Java "Integer" objects, to indicate "no value". This is different from zero. Java does have an "int"--which is nothing but a primitive number. It's not an "object". However, "Integer" is a "wrapper" for "int", which basically makes "int" an object. And the "Integer" can be NULL.
The Visual Studio 2005 Java Converter converted all my "Integer" objects to System.Int32. My code is then trying to move NULL to that, which doesn't compile. What is the standard way to handle this? Using zero, or negative one, won't be good enough. How do I indicate "this number is unassigned yet"?