what is the equivalent of StrReverse (which is vb.net) in c#

Hi experts,
I was following this example http://support.microsoft.com/default.aspx?scid=kb;en-us;309013

what is the equivalent of StrReverse (which is vb.net)  in c#

and How do i takecare of it??

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StrReverse is provided as one of the many little helper functions that existed in old school VB and many would want today... unfortunately, there is no official C# alternative.

Luckily though, because of the whole concept of the Base Class Library, you can still use it! In VB.NET when you call StrReverse, it calls the function Microsoft.VisualBasic.Strings.StrReverse(). In order to use it, you would have to set a reference to Microsoft.VisualBasic.dll... however this is generally frowned upon, but still legal and useful.

If you do not want to go this route... you will have to build your own.
Found this on Code Project .  Its a Reverse method that uses recursion.
(Credit goes to mosessaur.)

public static string Reverse(string strValue)
    // this is the Termination of the Recursion when the string
        // length is 1 means on char
        return strValue;
        //print the or store the 1st char every time,
        //so that when 1st Char stored will be the end of the string
        //this way the string will be reversed
        return Reverse( strValue.Substring(1) ) + strValue.Substring(0,1);

On second thought, I like using StringBuilder.  Make sure to add using System.Text; to the top

string sNormal = "testing";

StringBuilder sbReverse = new StringBuilder();
for(int i = sNormal.Length-1; i >= 0; --i )

string sReverse = sbReverse.ToString();


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

SirReadAlotAuthor Commented:
Hi paul, just tried out your code. I
SirReadAlotAuthor Commented:
opps!!!          I wonder if u know why this is happening.

error saying
Method 'TestHarness.WebService.Service.GetMessage()' referenced without parentheses
'TestHarness.WebService.Service' does not contain a definition for 'SendMessage'
'TestHarness.WebService.Service' does not contain a definition for 'ReverseMessageFunction'
'TestHarness.WebService.Service' does not contain a definition for 'ReverseMessageSub'

this is the client application code(console). it says

using System;
using System.Web.Services;
using TestHarness.WebService;

namespace TestHarness
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      class Class1
            static void Main(string[] args)
                  string strValue = "This is my message";
                  WebService.Service myService = new WebService.Service();


SirReadAlotAuthor Commented:
i have reduced the error down to

Method 'TestHarness.WebService.Service.GetMessage()' referenced without parentheses
'TestHarness.WebService.Service' does not contain a definition for 'SendMessage'

GetMessage() does exist in the service.asmx class,

can't figure out wat wrong


SirReadAlotAuthor Commented:
it actually worked.

thanks paul
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.