473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
Nov 17 '06 #1
3 1186
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.

zlfcn wrote:
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
Nov 17 '06 #2
zlf
Got it. Thank you:)
Nov 17 '06 #3
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

"zlfcn" wrote:
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
Nov 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Uwins | last post by:
Hi there, i know theres a number of ways I can achieve this but want to know the best, (but still quite simple). Up until a year ago I never used Access but have designed a few databases for...
13
by: MLH | last post by:
I have a number of reports that are essentially black 'n white prepared forms (picture an IRS form 1040). The data fields are overlaid onto the report fields in the correct positions and I would...
0
by: Karl | last post by:
Hi, In SQL server, I created a Person table with a spouseID field, which refers to PersonID as the foreign key. It is like this: PersonID (primary key), PersonName, SpouseID (foreign key refer...
20
by: Dennis | last post by:
I use the following code for a strongly typed arraylist and it works great. However, I was wondering if this is the proper way to do it. I realize that if I want to implement sorting of the...
6
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
0
by: Scott_from_Carematic | last post by:
I'm trying to use a strongly typed dataset in my asp.net (2.0) project with visual studio 2005. I have generated the dataset and tableadapters in the designer. I'm using SQL server EE 2005 as the...
3
by: dave | last post by:
I am having trouble accessing a property set during run-time in a user control that I have built. The control is supposed to connect to a database using the path supplied by the developer at...
0
by: =?Utf-8?B?RGF2ZSBU?= | last post by:
I have a list box that is bound to an object data source. I added a column, say ColumnC, to my typed data set (using the designer) and for the expression property I entered ColumnA + ': ' +...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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 projectplanning, coding, testing,...

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.