SirReadAlot
asked on
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??
thanks
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??
thanks
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
if(strValue.Length==1)
{
return strValue;
}
else
{
//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);
}
}
Paul
(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
if(strValue.Length==1)
{
return strValue;
}
else
{
//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);
}
}
Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi paul, just tried out your code. I
ASKER
opps!!! I wonder if u know why this is happening.
error saying
Method 'TestHarness.WebService.Se rvice.GetM essage()' referenced without parentheses
'TestHarness.WebService.Se rvice' does not contain a definition for 'SendMessage'
'TestHarness.WebService.Se rvice' does not contain a definition for 'ReverseMessageFunction'
'TestHarness.WebService.Se rvice' 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();
Console.WriteLine(myServic e.GetMessa ge);
Console.WriteLine(myServic e.SendMess age(strVal ue));
Console.WriteLine(myServic e.ReverseM essageFunc tion(strVa lue));
myService.ReverseMessageSu b(strValue );
Console.WriteLine(strValue );
}
}
}
thanks
error saying
Method 'TestHarness.WebService.Se
'TestHarness.WebService.Se
'TestHarness.WebService.Se
'TestHarness.WebService.Se
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();
Console.WriteLine(myServic
Console.WriteLine(myServic
Console.WriteLine(myServic
myService.ReverseMessageSu
Console.WriteLine(strValue
}
}
}
thanks
ASKER
i have reduced the error down to
Method 'TestHarness.WebService.Se rvice.GetM essage()' referenced without parentheses
'TestHarness.WebService.Se rvice' does not contain a definition for 'SendMessage'
GetMessage() does exist in the service.asmx class,
can't figure out wat wrong
thanks
Method 'TestHarness.WebService.Se
'TestHarness.WebService.Se
GetMessage() does exist in the service.asmx class,
can't figure out wat wrong
thanks
ASKER
it actually worked.
thanks paul
thanks paul
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.Stri
If you do not want to go this route... you will have to build your own.