Do lamda expressions work in UIPath?

Hello,

I’ve noticed that when using an expression with a lambda expression, UIPath always prompts an error with the following message “Expression expected”.

1 Like

UiPath uses VB.Net, not C#, so you need to use different syntax:
C#: .Where(x => x < 5) VB.Net: .Where(Function(x) x < 5)

More info:
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions

Also note that the = sign is interpreted differently depending on context (so it might mean an assignment or comparison, instead of = and == like in C# and some other languages).

8 Likes

Are you getting how to use lambda expressions in UIpath ?? If u are getting please help me how to use. Because i am also facing same issue what you were facing.

hey @MahalingPatil

It is already mentioned by @andrzej.kniola

if still you are still not able to make it… then share where you are getting problem.

Regards…!!
Aksh

2 Likes

Okay…Tq

@MahalingPatil
Hi, as also noted here, Telerik’s code converter comes in handy for converting from C# to VB.Net. However, it doesn’t like the dot notation, so for the lambda shown by Andrzej it will throw an error. Just remove the “.Where” and it correctly converts (x => x < 5) to (Function(x) x < 5).

You probably know about that already, but just in case :slight_smile:

Regards,
burque505

Tq…Its working for me

1 Like

Glad to hear it!