Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
C#
What should i do if i want to Reverse String ? Ex: string name= null; name=textBox1.text; After that what should i do? Thanks
8 Respostas
+ 1
string name = "", eman = "";
int nameLen;
nameLen = name.Length - 1;
while (nameLen >= 0)
{
eman = eman + name[nameLen];
nameLen--;
}
+ 1
https://code.sololearn.com/cw8P6mr0B6xh/#cs
^I always forget about the playground. There it is in action, if you wish to check it out.
Basically, you reverse it by creating a secondary string variable that we'll store the new word in, and then just iterate backward through the first string array, capturing the letter in each index and storing it in the secondary string variable.
Hope that helps.
string name = "", eman = "";
int nameLen;
Console.Write("What's your name? \n");
name = Console.ReadLine();
nameLen = name.Length - 1;
while (nameLen >= 0)
{
eman = eman + name[nameLen];
nameLen--;
}
Console.WriteLine("Your name forward is {0}\n", name);
Console.WriteLine("Your name backward is {0}\n", eman);
+ 1
When you're done, just assign the value of 'eman' to the variable 'name.'
string name = "", eman = "";
int nameLen;
nameLen = name.Length - 1;
while (nameLen >= 0)
{
eman = eman + name[nameLen];
nameLen--;
}
name = eman;
You don't have to continue using eman, it's just necessary to use it as a temporary variable so you can do the operations you need to do.
+ 1
Remove null
0
If we don't want to use string 2 . Ex: string name ,eman; how to do this ?
0
Thank you sir
0
Wow so good ,,, thanks sir
0
I want to ask you one more about Pair Letter ,
Example : book it is Pair letter
Car it is not Pair letter ,, how do we know about this?
Should we must do modulus or not ?