c# - loop that checks every char in a string -


i'm making cool thing makes secret letter can send friend, i'm having few problems. i'm trying make loop on every char in string string, can check if letter value , change it.

this code :

    private void button1_click(object sender, eventargs e)     {         string translatedtex = richtextbox1.text.tostring();               int indexletter = translatedtex.length;             (int item = 0; item < indexletter; item++)             {                 char normal_a = 'a';                   //   if(translatetext[item] = normal_a)              //   { //do              //    }                  if(translatetext[item] = "a")                 { //do                   }             }      } 

i've tried switch check of value between quotes "" '' or = == , nothing helps. shows error : - property or indexer string.this[int] cannot assigned -- read - cannot implicitly convert type char bool / string

i don't know want :d

but syntax correct now

private void button1_click(object sender, eventargs e)     {         string translatedtext = richtextbox1.text.tostring();               int indexletter = translatedtext.length;             (int item = 0; item < indexletter; item++)             {                 char normal_a = 'a';                   //   if(translatedtext[item] == normal_a)              //   { //do              //    }                  if(translatedtext[item] == 'a')                 { //do                   }             }      } 

and general knowledge:

"==" used comparison; "=" used assigning value

"a" used strings; 'a' used chars


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -