Nullable Types (C# Programming Guide)
Nullable types are instances of the System.Nullable
Examples:
a Nullable int32, pronounced "Nullable of Int32," can be assigned any value from -2147483648 to 2147483647, or it can be assigned the null value. a Nullable bool can be assigned the values truefalse, or null.
TheAddProductmethod take in as parameters the values for the various product fields and add a new product. Since many of theProducttable's columns can acceptNULLvalues (CategoryID,SupplierID, andUnitPrice, to name a few), those input parameters forAddProductthat map to such columns use nullable types [2]:
[System.ComponentModel.DataObjectMethodAttribute]
(System.ComponentModel.DataObjectMethodType.Insert, true)]
public bool AddProduct(string productName, int? supplierID,
int? categoryID, string quantityPerUnit, decimal? unitPrice,
short? unitsInStock, short? unitsOnOrder, short? reorderLevel,
bool discontinued)
{
(....)
}Related articles:
[1] - Nullable Types (C# Programming Guide)
[2] - Creating a Business Logic Layer
No comments:
Post a Comment