c# - can't remove the reserved character? -


i trying remove reserved character after calling function returns same input..

        public static void main(string[] args)         {             string text = "erhan?test*.pdf";                           remove(text);              console.writeline("this result : {0}", text);             console.readline();                     }           private static string remove(string str){               stringbuilder sb = new stringbuilder();              foreach (char c in str)              {                  if (char.isletterordigit(c) || c == '.' || c == '_' || c == ' ' || c == '%')                  { sb.append(c); }              }              return sb.tostring();         } 

in code not updating variable text (which honest cannot because string immutable), returning new string function remove. not using returned value anywhere, value lost.

in order make code workyou need assign variable text result of function:

text = remove(text); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -