Replace specific word - code explanation

Hello!

I have this code:
row(“yourcolumnname”) = “UBXH02-9”+(Convert.ToInt32(Split(row(“yourcolumnname”).ToString,“-”)(2).ToString)+1).ToString
I found it in this forum and now I have to describe it step by step for a documentation
But I’m not sure what this part means: (Convert.ToInt32(Split(row(“yourcolumnname”).ToString,“-”)(2).ToString)+1).ToString … can someone describe what each part means?

image

From the inside out:

row("yourcolumnname").ToString - the item in the column of the Datarow row converted to String format.

Split(...,"-")(2).ToString - Breaks the string at every instance of the - character. The (2) specifies to get the 3rd part split out. So if I have string “Hello-to-the-world”, the result would be “the”.

(Convert.ToInt32(...)+1).ToString - Converts the whole thing to an integer and adds 1. Then that number is converted back into a string.

1 Like

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