By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,960 Members | 2,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,960 IT Pros & Developers. It's quick & easy.

How do I assign null to an integer?

P: n/a
In C# integers are automatically intialized to zero. I need to assign
null to an integer (i.e. int i = null).

I cannot use Nullable Types because that is a feature in .NET 2.0 and I
need to use .NET 1.1.

Thanks

Oct 2 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

su***************@cubic.com wrote:
In C# integers are automatically intialized to zero. I need to assign
null to an integer (i.e. int i = null).

I cannot use Nullable Types because that is a feature in .NET 2.0 and I
need to use .NET 1.1.
You can't.

You must either:

1. Choose a value in the integer value range that you know your program
will never use, and assign it the meaning, "null":

const int NullCustomerId = -1;
int customerId = NullCustomerId;

or

2. Create a separate bool variable that will tell you whether the value
is null:

int customerId;
bool customerIdIsNull;

Oct 2 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.