Need help to understand the piece of code snippet

Good morning fellow UiPath Rock Stars,

I needed to implement a kill process into my workflow and was able to do it by using the For each loop logic and know how it works. As well I found another tutorial on YouTube where the guy explained it, but it was really short and I couldn’t understand the piece of code he used.So he did assign a code snipped to variable. The code snipped is below:

(From p As Process In process.GetProcesses Where p.ProcessName.ToUpper Like processName.ToUpper And Not GetAllRunningProcesses.Contains§)(0)

here is the link to YouTube tutorial ==> https://www.youtube.com/watch?v=-evauIzBZLE

It looks like querying something but I couldn’t get it. As I figured out ‘From p’ As, In, Where, Like, And

If anyone could explain me the code flow and from where it comes from it would be very helpful.

Thanks,
Thrall

Hi

Fine
this is actually a LINQ query where we are trying to get the process names of those process that are running currently inthe background
like

Taking p as a variable that stores the final value of processes

getting all the process names that are running in background with GetProcesses method

this is a where condition similar to how we use in SQL or other querying statements which states that the value of p is like processName.ToUpper (converting to upper)
this is done to obtain only the processname which are in upper case

i didnt get this as some junks mentioned and i hope it is checking for the process apart from the one that contains certain term or a string in it

and finally (0)
this mentions that we are trying to get the first value out of this LINQ query

hope this would help you
Cheers @Thrall

1 Like

@Palaniyappan

Thank you sooooo much. It is clear for me now.

1 Like

Cheers @Thrall

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