Click to See Complete Forum and Search --> : Some Questions


nemok
January 2nd, 2006, 12:22 PM
Hi, I am new to C# and I have a few questions:
How to reverse string in C#?
Can I use in C#, C++ string manipulation functions like strrev?
How to get a random numer that has a min and a max?

wildfrog
January 2nd, 2006, 12:30 PM
How to reverse string in C#?
Maybe you can convert the string to a char array, then use Array.Reverse(...), before you convert it back to a string.

Can I use in C#, C++ string manipulation functions like strrev?No.

How to get a random numer that has a min and a max?
You can use the System.Random.Next(min, max) function.

- petter

jhammer
January 2nd, 2006, 01:55 PM
In addition to wildfrog's post, the following code might be helpful:

string txt = "Something you want to reverse";
Char[] chr = txt.ToCharArray();
Array.Reverse(chr);
string reversedText = new String(chr);