I’m trying create a piece of code to do some string find/replace using InvokeCode but I’m running into a syntax error that I can’t figure out.
Dim test01 As String = “#first string# here is some text #second string# and more text”
Dim test02 As String = “#first string# here is some more text I don’t care about”
Dim items As New System.Collections.Generic.List(Of Integer)
items = test01.Select(Function(c, i) New With {.Character = c, .Index = i}) _
.Where(Function(item) item.Character = “#”) _
.ToList
Dim count As Integer = items.Count
This works in Visual Studio but I’m getting an error message that on the “items =” line: the List(Of anonymous type) can’t be converted to List(Of Integer)
@carlor
It seems to me that the part … new With creating an anonymus Object is forwarded as type to the toList() statement. Does mean. Statement is returning a list of anonymous object and not a list of Int
Give a try on test01.Select(Function(c, i) New With {.Character = c, .Index = i}) _
.Where(Function(item) item.Character = “#”) _
.ToList.Count() (As you are finally interested on the count, right?)
or use a Select before toList for projecting a dedicated part of the anononymous object
Ah. It’s a console application in VS. The code compiles in VS and runs fine. The problem is that the same code, in the UIPath “InvokeCode” has an error.
Thanks, but I’m not interested in the count. I’m only using that as a test to see if this works. What I want to do is the string manipulation I mentioned above.