baltmann
asked on
How to test if variable is assigned?
System.DateTime d;
How do you test if the variable d has been assigned?
What about
int i;
?
How do you test if the variable d has been assigned?
What about
int i;
?
eh?
as far as i understood..
int i;
....
if (i!=null) // if the variable has been assigned
{
...
}
int i;
....
if (i!=null) // if the variable has been assigned
{
...
}
ASKER
The compile errors are:
with DateTime:
System.DateTime dt ;
if(dt != null)
...
Operator '!=' cannot be applied to operands of type 'System.DateTime' and '<null>'
with int:
int i;
if(i==null){i=0;}
...
Operator '==' cannot be applied to operands of type 'int' and '<null>'
with DateTime:
System.DateTime dt ;
if(dt != null)
...
Operator '!=' cannot be applied to operands of type 'System.DateTime' and '<null>'
with int:
int i;
if(i==null){i=0;}
...
Operator '==' cannot be applied to operands of type 'int' and '<null>'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.