Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 18th, 2005, 04:06 PM
Authorized User
Join Date: Jul 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to yossarian Send a message via AIM to yossarian Send a message via MSN to yossarian Send a message via Yahoo to yossarian
Default C# null value assignment to numerical type

I'm assigning values to an ADO recordset in C#. Some of the numerical fields (integer) are assigned the value of "null"; however, when I check the value of the recordset field when it is passed to another method it is now '0'. If I don't do the assignment, the recordset field stays null. Is this typical behavior for C# that if a null value assignment is made to a numerical type -- the value is initialized to 0? String fields stay null when the null assignment is made.

Old January 21st, 2005, 08:22 AM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

In a database an integer column can be null. In .NET integers are native value types and can not be null. You should not be able to assign null to a integer variable. A new integer defaults to 0 (i'm pretty sure). If you want to assign null to a value to be saved to the database, try assigning DBNull.


Similar Threads
Thread Thread Starter Forum Replies Last Post
assign numerical values to text ptrussell2009 Excel VBA 9 October 8th, 2017 04:38 AM
behaviour of NULL value in date type columns kasanar SQL Server 2000 2 July 7th, 2005 04:40 PM
Getting Numerical Values Fiddleman HTML Code Clinic 2 September 13th, 2004 02:51 PM
How to extract numerical values from string? Genuine Beginning PHP 7 August 7th, 2004 07:49 AM
textbox with numerical values must C# 1 August 7th, 2003 12:44 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.