How to tell user an int typed field/property has not been set.

Z

zlfcn

Hi all,

In java, if a field is Integer type, we can assign it to null indicating
that this field has not been set yet. How can we achieve that in C#? In C#,
"int" is struct, we cannot set it to null. Thank you

zlf
 
M

Martin Z

If you're using version 2.0, google "Nullable Types". And int is not
exactly a struct, it's a value-type, where structs are also
value-types.
 
G

Guest

If your not in .NET 2, I used to use int.minvalue as null equivilent.
It does need converting to put it in a db though.

Ciaran O'Donnell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top