Take any example to build the data table and find the middle character in Name

excel

#1

how to write logic for finding the middle character of the string and what are the activities we need to apply.


#2

Hi @rreddyp,

you can get the middle character using this code below
String variable variable2

variable2.Substring(Convert.ToInt32(variable2.Length/2),1).ToString

Regards,
Arivu


#3

@rreddyp, Can you please change the tag from Uipath Jobs and News to RPA Dev and How to category ?

Those tags were meant for jobs and news in uipath that would mislead someone.

Regards,
Dominic :slight_smile:


#4

@rreddyp @arivu96
Suupose if the length of the string is even then you will not get middle character. there will be two middle characters.

Regards,
Mahesh


#5

Hi @MAHESH1,

yes you are right. @MAHESH1 @rreddyp refer this code.

int length = inputString.Length;

        Double   midvalue = length /2;

        if (length % 2 != 0)

        {

            int mid = Convert.ToInt32(midvalue);

            char[] InputString = inputString.ToCharArray();

           return InputString[mid].ToString();

        }

        else

        {

            return "Sorry, we can't give the Result";

        }         

Regards,
Arivu