Numbers andProgramming LanguageNumbers in the database can be empty, and numbers in C # cannot be empty. Int32 is a structure, while the structure is of the value type. Therefore, it cannot be empty.
In C #, you can use the nullable <t> structure to easily solve this problem.
Define an empty type:
Nullable <int> X; Int? X2;
Check the hasvalue and value Attributes of nullable <t>.
Nullable <int> X; X = 4; x + = 3; if (X. hasvalue) {int y = x. value;} X = NULL;
NULL data types can also use Arithmetic Operators. The X3 variable is the sum of the X1 and X2 variables. If one of the two empty variables is null, their sum is null.
Int? X1 = getnullabletype ();
Int? X2 = getnullabletype ();
Int? X3 = X1 + x2;
Convert the data type that can be empty to non-empty:
First, display Conversion
Int? X1 = getnullabletype ();
Int Y1 = (INT) x1
Second, it is safer to use the concatenation operator to convert
Int? X1 = getnullabletype ();
Int Y1 = x1 ?? 0;
When you use the getnullabletype () method, you will find such an error message.
The name 'getnulllabletype' does not exist in the current context
This should be because the namespace of the getnullabletype method is not added, but the namespace in which this method does not find o (operator □operator) O