Reverse logic for string
If we pass the ref type of string as a parameter.
It will the method reverseString will reverse your string
The below code is used to reverse your string
public void reverseString(ref string MyString) {
string tempStr = "";
int i, j;
Console.WriteLine("Reversing your string");
for(j=0, i=MyString.Length-1; i >= 0; i--, j++)
tempStr += MyString[i];
MyString = tempStr;
}
Code Explanation
1. Pass the ref type string as a parameter
2. create the variables tempstr,i,j
3. use the for loop logic as above you can get the reversed string as out put
By
Nathan
yes its a good logic and in vb.net we can use the vb inbuilt function:
MessageBox.Show(StrReverse("deepak"))
it will show: kapeed
regards
FoolToCode