how to assign a null value to an int
-
hi, i just want to ask if there is a way to asign a null value to a variable of type int. for example i can write this:
String testingString = null;
while writting this gives an error:int testingInteger = null;
The error is: Can not convert null to 'int' because it is a value type i am using this to assign a null value in database. meaning the textbox the i take from it the value of the integer is empty i want to insert a null value in the database not an empty cell. thanks in advance, -
hi, i just want to ask if there is a way to asign a null value to a variable of type int. for example i can write this:
String testingString = null;
while writting this gives an error:int testingInteger = null;
The error is: Can not convert null to 'int' because it is a value type i am using this to assign a null value in database. meaning the textbox the i take from it the value of the integer is empty i want to insert a null value in the database not an empty cell. thanks in advance,quiteSmart wrote:
i just want to ask if there is a way to asign a null value to a variable of type int
If you are using .NET 2.0 you can use nullable types. You just add a question mark to the value type to make it nullable:
int? myVariable = null;
quiteSmart wrote:
i am using this to assign a null value in database.
Just remember that when you are assigning null to a database you have to convert it to a
System.DBNull.Value
Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
hi, i just want to ask if there is a way to asign a null value to a variable of type int. for example i can write this:
String testingString = null;
while writting this gives an error:int testingInteger = null;
The error is: Can not convert null to 'int' because it is a value type i am using this to assign a null value in database. meaning the textbox the i take from it the value of the integer is empty i want to insert a null value in the database not an empty cell. thanks in advance,Because................ String is a reference type and int is value type........
Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com