Udostępnij za pośrednictwem


Nullable Sample

This sample demonstrates how to use nullable types. A nullable type is a value type such asint , double , bool, and so on that can have a value of null.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To build and run the Nullable Code sample within Visual Studio

  1. Open Nullable.sln, the solution file, either by double-clicking the file from Windows Explorer, or by clicking Open on the File menu.

  2. On the Debug menu, click Start Without Debugging.

To build and run the Nullable Code sample from a command prompt

  1. Use the Change Directory (cd) command to change to the \Boxing, \Basics, or \Operator subdirectory under the Nullable directory.

  2. For the Boxing sample, type the following:

    csc Boxing.cs
    Boxing
    

    For the Basics sample, type the following:

    csc Basics.cs
    Basics
    

    For the Operator sample, type the following:

    csc Operator.cs
    Operator
    

See Also

Concepts

Visual C# Samples

Reference

Nullable Types (C# Programming Guide)