How do I convert an IEnumerable<QueueItem> into a string? Or, can I check if a value exists in it?

As title describes, I have a variable of pCurrentQueueItem which contains a value I need to check against a string.

How do I convert it to a string in order for it to be read/compared?

Alternatively, is there a way I can check is a string exists within it? I essentially want to check if the value of ‘Reference’.
Thanks for your help.

Hi @dr1992

Queueitems.Where(function(x) x.Reference.Equals("Whtever you want to check")).Count > 0 will give if any reference is matching or not in given Ienumerable queue items reference

cheers

3 Likes

Hi @dr1992,

You can achive 2 ways

  1. you can able to convert to str

String.Join(“”,list_test)

  1. you do Contains it will return boolean value

list_test.Contains(“YourValue”)

Hey, I don’t think either of these worked, or I’m doing them wrong. The iEnumerable is stored as ‘pCurrentQueueItem’ - where would that need to go?

You can’t convert IEnumerable[QueueItem] into a string. When you say the value of Reference, do you mean the Reference column you see in the Orchestrator Queue, or do you mean you have a name/value pair (with name “Reference”) inside the queue items?

If you want the actual built-in queue item Reference that you see in Orchestrator, you get it this way…

yourQueueItemVar.Reference

So if you’re looping through an IEnumerable[QueueItem] and need to check each queue item, using pCurrentQueueItem as the loop variable, then it’s just pCurrentQueueItem.Reference

If you’re talking about a value within the queue item, that is coincidentally named Reference, then you’d do pCurrentQueueItem.SpecificContent(“Reference”).ToString

Exactly what I needed, thank you sir.

2 Likes

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