RPA Academy : String manipulation methods: message.Split(“.”c).First.ToString.Substring(message.LastIndexOf(“author”))

A similar question was asked and answered, but the answer is insufficient. My problem is with step #2 where First() is applied to the string array produced by Split(). First() not a legal method that applies to a string array in .NET. That will not compile in Vb.net.

First() is applicable to things such as List or a “sequence” in LINQ.
But somehow this statement works in the uiPath workflow! It will not compile in Vb.Net.

Can somebody explain if UiPath is casting this string array to a List or some other data type in the background?
Rather than VB.net, the example statement looks a lot like the fluent method syntax used in LINQ.

Hello @charles.ross.oh!

It seems that you have trouble getting an answer to your question in the first 24 hours.
Let us give you a few hints and helpful links.

First, make sure you browsed through our Forum FAQ Beginner’s Guide. It will teach you what should be included in your topic.

You can check out some of our resources directly, see below:

  1. Always search first. It is the best way to quickly find your answer. Check out the image icon for that.
    Clicking the options button will let you set more specific topic search filters, i.e. only the ones with a solution.

  2. Topic that contains most common solutions with example project files can be found here.

  3. Read our official documentation where you can find a lot of information and instructions about each of our products:

  4. Watch the videos on our official YouTube channel for more visual tutorials.

  5. Meet us and our users on our Community Slack and ask your question there.

Hopefully this will let you easily find the solution/information you need. Once you have it, we would be happy if you could share your findings here and mark it as a solution. This will help other users find it in the future.

Thank you for helping us build our UiPath Community!

Cheers from your friendly
Forum_Staff

I did all those things. The question remains unanswered. In Stack Overflow, I would get the Tumbleweed badge! Your course would be improved if the code portions in technical solutions were explained.

Try to compile and run this in VB.Net:

Module Program
    Sub Main(args As String())


        Dim str() As String =
            {"First", "Second"}
        Dim str2 As String

        Dim first As String = str.First()
        str2 = "Another string"

        Console.WriteLine(first)
        Console.WriteLine(str2.Split(" "c).First())

    End Sub
End Module

Sure, tried that on Online VB Compiler - online editor

Result:

Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.6 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.
/home/main.vb (14,35) : error VBNC30456: ‘First’ is not a member of ‘System.String’.
/home/main.vb (18,44) : error VBNC30456: ‘First’ is not a member of ‘System.String’.
There were 2 errors and 0 warnings.

As I mentioned, a String array has no “First” method.

Because System.Linq is imported in your workflow, Enumerable.First() can be used
https://docs.microsoft.com/ko-kr/dotnet/api/system.linq.enumerable.first?view=netcore-3.1

By importing System.Linq namespace, you can use their methods
If you remove that namespace from your workflow, it will throw error.

2 Likes

Uipath academy has gone worst after recent updates ,the speaker just doesn’t explain what he is doing and someone like me who is a new learner has to go through multiple links to understand a single step.
even by now I haven’t understood why he used “First” in this activity message.Split("."c).First.ToString.Substring(message.LastIndexOf(“author”))

Thanks, @Dongjin_Lee; this makes sense! If it was to be explained better in the course, wouldn’t that be great?

Yeah, many loose ends. I think they follow the “if it doesn’t kill you it makes you stronger” approach. It does encourage lots of searching and document finding. This section says it takes 6 hours but I did all the practices on my own without looking at the solutions and it took me more like 6 days. Slowing down the video playback speed can be helpful sometimes.

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