c# - How do i make my void comiler read a string and print in the MessageBox what is after it? -


 namespace windowsformsapplication1    {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }          private void form1_load(object sender, eventargs e)         {          }          private void compiler()         {             string print = "print hello world";             string sp = print.substring(print.indexof(' ') + 1);             messagebox.show(sp, "console");         }          private void tb_textchanged(object sender, eventargs e)         {          }          private void runtoolstripmenuitem_click(object sender, eventargs e)         {             compiler();         }     }     } 

i tested out , on start prints hello world. i'm trying in text box can read have typed "print" , whatever after space (ex: "print " < space right there) print text. hope made clear enough you! says "print hello world" , on start (when debug) shows message saying hello world, i'm trying read text box (tb) , if says "print" print whatever after it.

not clear need may help?

   namespace windowsformsapplication1    {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }          private void form1_load(object sender, eventargs e)         {          }          private void compiler()         {             string print = tb.text;             if (print.tolowerinvariant().startswith("print ")             {               string sp = print.substring(print.indexof(' ') + 1);               messagebox.show(sp, "console");             }         }          private void tb_textchanged(object sender, eventargs e)         {             compiler();         }          private void runtoolstripmenuitem_click(object sender, eventargs e)         {             compiler();         }     }     } 

Comments