C# .NET - check for null for integer
Asked By vickey ap on 04-Apr-13 03:32 AM
I have an int variable psid which populate clsid from a class.
Code is given below.
int psid = edoCom.clsid;
I want to check whether it is null or not. After checking i have to write certain condtions .
What is the best way to check whether it is null or not.
I am using framework 4.0 and C#.net.
please help me.
thanks in advance.
abdul rehman replied to vickey ap on 08-Apr-13 07:34 AM
Hi,
u can use the concepts nullable datatypes
? represent nullable datatypes try it
int? psid = null; //global declaration
int psid = edoCom.clsid;
if(psid!==null)
{
u r condition
}
example:
int? num1 = null;
int? num2 = 45;
Thanks
Abdul