Hi Team Please help me to reverse string

Hi Team,

My string value str=“Betti-Ann Lavitt”

but I need output as like output=“Lavitt Betti-Ann”

please help me on these team

Regards,
Saikrishna

@Mada_Sai_Krishna

str.Split(" "c).Last() & " " & str.Split(" "c).First()

Hi @Mada_Sai_Krishna

Input.Split(" "c)(1) + " " + Input.Split(" "c)(0)

Regards,

Can you send C# code

@Mada_Sai_Krishna

Input.Split(' ')[1] + " " + Input.Split(' ')[0];

Regards,

Hi @rlgandu ,

can you send the C# format

@Mada_Sai_Krishna,

Here is simple approach can handle any length of the string.

strOutput = String.Join(" ","Lavitt Betti-Ann".Split(" "c).Reverse)

image

Thanks,
Ashok :slight_smile:

@Mada_Sai_Krishna

 output = string.Join(" ", str.Split(' ').Reverse());

Hi,

How about the following?

String.Join(" ",str.Split(" ",StringSplitOptions.RemoveEmptyEntries).Reverse())

Regards,

Hi @Mada_Sai_Krishna

original = "Betti-Ann Lavitt";

reversedWords = String.Join(" ", original.Split(new[] { " " }, StringSplitOptions.None).Reverse())

Regards

it’s worked.
Thankyou @Yoichi

1 Like

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