c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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.

19th Jul 2017, 6:55 AM
lee ratana
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
19th Jul 2017, 7:22 AM
Limitless
Limitless - avatar
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
19th Jul 2017, 8:19 AM
lee ratana
0
so you want to write "do or" and count all the letters and not just the characters?
19th Jul 2017, 11:20 AM
Limitless
Limitless - avatar
0
I use character ,, but I don't know to use this ,, I so not clever ,
19th Jul 2017, 11:38 AM
lee ratana
0
you mean "?
19th Jul 2017, 12:29 PM
Limitless
Limitless - avatar
0
Sorry . "Do or" .
19th Jul 2017, 10:57 PM
lee ratana
0
What is your home language? Maybe that will make it easier to understand
20th Jul 2017, 7:01 AM
Limitless
Limitless - avatar
0
Cambodia
20th Jul 2017, 8:17 AM
lee ratana