Nullable long : Nullable « Data Type « C# / CSharp Tutorial






using System;

public class Employee
{
    public Employee( string Name ) {
        this.firstName = firstName;
        this.terminationDate = null;
        this.ssn = default(Nullable<long>);
    }

    public string firstName;
    public Nullable<DateTime> terminationDate;
    public long? ssn; 
}

public class MainClass
{
    static void Main() {
        Employee emp = new Employee( "A");
        emp.ssn = 1234567890;

        Console.WriteLine( "{0} {1}", emp.firstName);
        if( emp.terminationDate.HasValue ) {
            Console.WriteLine( "Start Date: {0}", emp.terminationDate );
        }

        long tempSSN = emp.ssn ?? -1;
        Console.WriteLine( "SSN: {0}", tempSSN );
    }
}








2.54.Nullable
2.54.1.null unification
2.54.2.Nullable long
2.54.3.Nullable Struct
2.54.4.Nullable Types Access: Explicitly use properties
2.54.5.Nullable Types Access: shortcut syntax
2.54.6.Nullable Types Assignment
2.54.7.Null Coalescing Operator
2.54.8.A nullable type
2.54.9.Use nullable objects in expressions: result contains null, because one operand is null
2.54.10.Assign value to nullable int
2.54.11.Using ??