How to compare two strings

Hi All:

Now, I have two strings. A=“10”,B=“10”, I used A.Equals(B), but it can’t recognize A equals B. I used A=B, it still can’t recognize A equals B. So how to compare two strings are same?

By the way, I think there are lots of functions, such as Length/Substrinf/Trim/End… Where I can learn these functions? I think they are very important for develop.
Thanks in advance !

Use Assign boolean1 = string.equals(A,B)

Result will be true.

Also you can convert it to integer and compare

Convert.Toint32(A) = Convert.Toint32(B).

There are many tutorials for string manipulations. Just search in Google as c# string manipulations. Few are below.

@Vivek_Arunagiri Thanks very much! But,why I can’t compare them directly ?

Hi this is my workflow.Main.xaml (16.8 KB)

I set C is “1103”, and I want to get the date from computer system date. I edit they are same string, but when I compared them, they are different ! I am so confused !

Check the data type when you getting time from system and not concertin taht to short time it will be considering with mins and seconds as well. Hence your check will fail.

@Divyashreem Sorry, I am not very clear about the contents that you mentioned. Can you give me more details, by the way, the variables all are “string”. So what kind of data type should I check again?:neutral_face::tired_face:

Hey @Harvey,
Some small tweaks i made accordingly to fetch date and compare with C =1104


  1. GetDateText was returning "System Clock, 2:19 AM, ‎11/‎4/‎2018" so i substring it to only 11/4/2018
  2. day split changed a little as .Split(Char.Parse("/"))(3) returns 2018 and not 4 so now its Split(Char.Parse("/"))(1)
  3. full_date changed as Split(Char.Parse("/"))(0)+day same reason.

11/4/2017 -> split {“11”->position 0,“4”->position 1,“2018”->position 2}

  1. Changed the type of C and full_date to UiPath.Core.GenericValue to allow compare of number strings without conversion.

More details at:

Tested xaml file on my system : Main.xaml (18.8 KB)

Let me know if it works for you

@nadim.warsi Thanks very much ! So I got the point ! String can’t be compared ! UiPath.Core.GenericValue can be compared !

1 Like

Not exactly. Number only strings is what is not compared. So we use a different type to do the ‘=’

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