Recent Posts

Tuesday, September 2, 2008

How to reverse a string in .Net

This simple example explains many different small utilities in .Net that might
take hours to explore on the net.

First lets talk about reversing the string

This can be done in many ways but two simple ways I am explaining is as follows

1. first way

You can use StrReverse(string) function and to use that you have to use
imports Microsoft.visualbasic

This function will simply reverse the string .

2 The next way

Look at the following code for reversing the string

str = txtInput.Text


Dim charArray() As Char = str.ToCharArray
charArray.Reverse(charArray)

Dim alphabet As New String(charArray)


lblDisplay.Text = alphabet



The above piece of code also explains

How to convert string into character array?
Dim charArray() As Char = str.ToCharArray

and

How to reverse an array?

charArray.Reverse(charArray)

and

How to convert character array into string?

Dim alphabet As New String(charArray)

Related Posts by Categories




No comments:

Post a Comment