I believe this is what you're looking for
string oldstr = "Hello World";
string s = oldstr.Replace(" ", "_");
(s == "Hello_World");
Question
Suppose initial string is
String result= "Welcome To All" for that i need updated result as
String result="Welcome_To_All" string value is dynamic,how can i do that,thank for help?
Solution
I believe this is what you're looking for
string oldstr = "Hello World";
string s = oldstr.Replace(" ", "_");
(s == "Hello_World");
OTHER TIPS
I'm going to guess that you're using javascript and you're ok with using regular expressions.
result = result.replace(/ /g, "_");