473,471 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I assign null to an integer?

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
1 9664

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John | last post by:
Ok. I'm not sure whether this is cool or perverted, I need second opinion ;) I define two classes as follows: /********************************************/ public sealed class Dummy {...
3
by: vince | last post by:
I want to assign a null value to a DateTime variable.How do i do that? Thanks Vince
2
by: Lenard Gunda | last post by:
Hey, How can I assign 'null' value to a handle in C++/CLI? I searched for this for some while now, finding nothing so far. In C# I could write: something = null; or
2
by: Jim McGivney | last post by:
In asp 2.0 I am trying to insert a row using a detailsview control connected to an accessDataSource. I get the error message below. I am having trouble identifing which data field is causing the...
14
by: mast2as | last post by:
Hi everyone, I am trying to implement some specs which specify that an array of parameter is passed to a function as a pointer to an array terminated by a NULL chatacter. That seemed fairly easy...
3
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a String that i need to DateTime.Parse() and if a FormatException occurs I need to assign a null to my DateTime variable. The only way i know to do this is DateTime.MinValue or...
42
by: polas | last post by:
Afternoon all, I have some code (which I thought was OK, but now appreciate is probably not by the standard) which contains int a; ...... if (a==NULL) { ....
2
by: kishore84 | last post by:
Hi, I am new to this forum. please suggest about my query regading reference mentioned in the title. also please suggest some good books for c++ that is apropriate for c++ developers. ...
1
by: Rob Singer | last post by:
For example, suppose I have this: #define TYPE_4_ERROR (1<<2) int error_number; error_number = TYPE_4_ERROR; Do I have the value of decimal 4 in error_number or do I have something else?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.