Removing null from IEnumerable <Object>

Hi guys,

I need to remove an object, in this case null from a IEnumerable <Object> .
It looks like this:
objArticle = object[9]

{
  null,
  756944007,
  756845001,
  2226611000,
  2225708000,
  2226616005,
  2226738004,
  757034002,
  756905002 
}

I just want to remove the null, where the index of the null is not always in the beginning.

Hi @titatarik ,

Could you try the below :

objArticle = objArticle.Where(Function(x)Not(x is Nothing))
1 Like

@titatarik

A more intuitive check

ObjArticle.Where(function(x) Not IsNothing(x) OrElse Not String.IsNullOrEmpty(x.ToString))

Cheers

Thanks for the answer. Unfortunately it results in the error: “Option Strict On” can not convert Object to String.
The answer above is working though.

1 Like

Thanks! Working perfectly

1 Like

@titatarik

Mussed adding .ToString…edited the same…anyways you got the solution

Happy Automation

Cheers

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