New course! Every coder should learn Generative AI!
Try a free lesson0
c#
int a =0; string name=textBox1.Text.Trim(); char[] ch= name.ToCharArray(); a=ch.Length; for(int i =ch.Length-1; i>=0;i--) { if(a %2 ==0) { richTextBox1.Text += ch[i].ToString(); richTextBox1.ForeColor= Color.Red; } else { richTextBox1.Text += ch[i].ToString(); richTextBox1.ForeColor= Color.Black; } Why when we write like this "do or " it count 5 letter include ? Can you explain it? And show how to show "do or" like this include 4letter in it.
8 Answers
0
In the his example you can see how to remove all the spaces in a string, but why do we want to remove spaces?
To answer your and my question:
Strings are basically an array of Characters, everything that takes up space like a comma, fullstop, number, letter or even a space takes up character space, so when you get the length of a string it basically see how many characters are present. This means that you can control how many characters are in a string.
https://code.sololearn.com/cBjdBVE4eF1G/?ref=app
0
Thanks for your answer , But when remove space i want show like this
"do or" not "door"
This word refer to length Right?
If I witre this "do or " length show 5 letter
But when I wrote this "door" length show 4 letter . I mean when I wrote "do or " like this length count 4 letter
0
so you want to write "do or" and count all the letters and not just the characters?
0
I use character ,, but I don't know to use this ,, I so not clever ,
0
you mean "?
0
Sorry . "Do or" .
0
What is your home language?
Maybe that will make it easier to understand
0
Cambodia