All Topics  
Nullable Types

 

   Email Print
   Bookmark   Link






 

Nullable Types



 
 
In programming, nullable type is a feature of some programming languages which allows a data type
Data type

A data type in programming languages is an attribute of a data which tells the computer something about the kind of data it is. This involves setting constraints on the datum, such as what values it can take and what operations may be performed upon it....
 to be set to NULL instead of their common range of possible values. In contrast, object references or pointers can be set to NULL by default in most common languages, meaning that the pointer or reference points to nowhere, that no object is assigned (the variable contains nothing). For value or data types like integer
Integer

The integers are natural numbers including 0 and their negative and non-negative numberss . They are numbers that can be written without a fractional or decimal component, and fall within the set ....
s and boolean
Boolean datatype

In computer science, the Boolean algebra datatype, sometimes called the logical datatype, is a primitive datatype having one of two values: Truth value and false....
s however, such behavior is mostly not possible.






Discussion
Ask a question about 'Nullable Types'
Start a new discussion about 'Nullable Types'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In programming, nullable type is a feature of some programming languages which allows a data type
Data type

A data type in programming languages is an attribute of a data which tells the computer something about the kind of data it is. This involves setting constraints on the datum, such as what values it can take and what operations may be performed upon it....
 to be set to NULL instead of their common range of possible values. In contrast, object references or pointers can be set to NULL by default in most common languages, meaning that the pointer or reference points to nowhere, that no object is assigned (the variable contains nothing). For value or data types like integer
Integer

The integers are natural numbers including 0 and their negative and non-negative numberss . They are numbers that can be written without a fractional or decimal component, and fall within the set ....
s and boolean
Boolean datatype

In computer science, the Boolean algebra datatype, sometimes called the logical datatype, is a primitive datatype having one of two values: Truth value and false....
s however, such behavior is mostly not possible. Nullable Type support allows for the programmer to make also these value types NULL. This can be very useful when working with databases. A field in a Relational database
Relational database

A relational database is a database that groups data using common attributes found in the data set. The resulting "clumps" of organized data are much easier for people to understand....
 like SQL
SQL

SQL is a database computer language designed for the retrieval and management of data in relational database management systems , database schema creation and modification, and database object access control management....
 may have an entry that is NULL
Null (SQL)

Null is a special marker used in SQL to indicate that a data value does not exist in the database. Introduced by the creator of the Relational model database model, Edgar F....
 (or empty) instead of containing a value. A language with Nullable Type support can then return a NULL value and correctly represent the behavior of the database.

Example


An integer variable may contain a positive or negative natural number
Natural number

In mathematics, a natural number can mean either an element of the Set = *n = = ? = ? ...
 ( ..., -2, -1, 0, 1, 2, ...). The value 0 (zero) however is not the correct representation for this variable to contain nothing (it contains the value 0 and only the conception in the given context might suggest that 0 represents "nothing" instead of the actual representation: "nothing" of "something"). In many circumstances it is required to represent also the fact, that a variable has not been given any value at all. This can be achieved by a Nullable Type. In programming languages like C# 2.0 a Nullable integer for example can be declared by a question mark (int? x).

A boolean variable makes the effect even more clear. Their values can be either "true" or "false", while a nullable boolean may also contain a representation for "undecided". However, the interpretation of logical operation containing boolean nullable variables is up to the language that is being used.

Languages with Nullable Type support


  • .NET Framework
    .NET Framework

    The Microsoft .NET Framework is a software framework that is available with several Microsoft Windows operating systems. It includes a large Library of coded solutions to prevent common programming problems and a virtual machine that manages the execution of programs written specifically for the Software framework....
     version 2.0 languages
  • Oxygene