Need to check if my Innumerable variable retuning Null or Not

Hi All,

In my project I have used Regex and in output an innumerable variable it is returning. I want to conditionalize my code, if that innumerable variable is returning null value or not. Can anyone help me to do that.

E.g.
Innumerable Variable = X

I am checking with condition in if statement → X(0).ToString = “”
And X(0).ToString = null

my code is getting stopped every time with this condition.

Thanks,
Baruna K Panda

Lets assume you have an IEnumerable(Of Match) - myMatches

Check: myMatches is null we do check - isNothing(myMatches)
Check: myMatches is returned but did not have matches - myMatches.Any()

Hi ppr,

I tried as you suggested, but it is working fine for variable having value, but getting failed for variable returning null.

I have given if condition, it is getting away. Pleas refer the attached images for your reference.


Thanks

In general we do prototype / check our ideas within immediate panel:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

we can compose a needed construct from following building blocks:

Check if myMatches was returned with matches:
myMatches.Any()

Check if e.g. the access to a particular index is available or not:
isNothing(myMatches.ElementAtOrDefault(1))

Also have a look here:

Case - not matches found:
grafik

Case - match was found checking first()
grafik

But there is no second match:
grafik

where the long constructs for the dedicated element acces check can be simplified to:
grafik
with the meaning true: does not exist

hi @Panda_Baruna_K

You can try like this

Innumerable Variable.Count=0

Regards
Sudharsan

1 Like