Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

ASP.NET: Reverse a string

From Wiki

Jump to: navigation, search

Summary: Reverse a string

Here's a couple of simple methods you can use to reverse a string:

  1. Partial Class Default1
  2.     Inherits System.Web.UI.Page
  3.  
  4.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  5.         Response.Write(ReverseString("olleh"))
  6.     End Sub
  7.  
  8.     Public Function ReverseString(ByVal targetString As String) As String
  9.         Dim Characters() As Char = targetString.ToCharArray
  10.         Array.Reverse(Characters)
  11.         Return Characters
  12.     End Function
  13.  
  14.     Private Function ReverseString2(ByVal targetString As String) As String
  15.         Return StrReverse(targetString)
  16.     End Function
  17. End Class

Output:

  1. hello


This Hack is part of the ASP.NET Hacks collection

483 Rating: 0.0/5 (0 votes cast)