Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is Nullable Type in C#

    • 0
    • 1
    • 1
    • 3
    • 0
    • 0
    • 0
    • 0
    • 155
    Comment on it

    The Nullable Types in C# language:

    The nullable data types were included to value data types with C# language in the year 2005. This feature allows us to assign the null value to a value-type variables. You need this functionality with databases where a variable can be assigned any value including null value. The nullable variable is declared by using the ? symbol next to the data type name, like below:

     customType? customType;
    

    where customType is one of the value data types including the struct data type. It is called the underlying data type of the nullable data type. For example, let us assume the following statement:

    int customInt? = null;
    

    In above statement, the underlying data type is int. This states that the variable customInt can accept all the values that can be assigned to int in addition to null, which means not used or empty. In the following example,

    bool customBool?;
    

    customBool can assume one of the values true, false, or null. When working with databases, this feature is vital because a database field may contain null values to indicate that the variable is undefined.A vary same concept also applies with reference types where the value null has been used to indicate that a variable is not initialized.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: