String is null ,empty and zero

Hi All,
I have an value in string ,and i want to check it is null, empty or zero.
so,when string is null or empty that time I use string.IsNullorEmpty(Variablename)
but, for zero checking I am getting error.
kindly, suggest me

Regards,
Meenakshi

1 Like

Hi
String.Isnullorempty method will check only for null value or empty
while zero is different from null
for zero it should be like
StringVariable.ToString.Equals(β€œ0”)

Cheers @Meenakshi6246

1 Like

for zero its not working

1 Like

Kindly try this and let know for any queries or clarification or
if we want both together to be validated
then
string.IsNullorEmpty(yourvariable) or yourvariable.ToString.Equals(β€œ0”)

Cheers @Meenakshi6246

2 Likes

@Meenakshi6246 You can check two coditions string.IsNullorEmpty(Variablename) or Variablename.ToString="0"

did that work buddy
Cheers @Meenakshi6246

yes,
Thank you

1 Like

Fantastic
Cheers @Meenakshi6246

To check null in JavaScript, use triple equals operator(===) or Object.is() method. To find the difference between null and undefined, use the triple equality operator or Object.is() method.

To loosely check if the variable is null, use a double equality operator(==). The double equality operator can not tell the difference between null and undefined, so it counts as same. So if you want to strict check, then don’t use a double equality operator. It will lead to misconclusion.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.