M3hcSS
asked on
Replace string function in C# working in web forms but not win forms.
He says:
What am I missing here?
I have the following string:
string _node = Individual_Program__Serio us_Inciden ts_Sorted_ by_Inciden t_Report
I use the following C#
_node.Replace(-,_).
I am trying to replace the dash with an underscore. After the code executes, it is still a dash!!!
Any suggestions?
I reply back:
Heres your answer&
protected void Page_Load(object sender, EventArgs e)
{
string myNode=
@"Individual_Program__Ser ious_Incid ents_Sorte d_by_Incid ent_Report ";
Label1.Text=myNode;
myNode=myNode.Replace("_", "-").ToStr ing();
Label2.Text=myNode;
}
He says:
Im not using ASP. This is in my code generator.
Its maddening& this doesnt work:
string _treeNode = ri.treeNodeName.Replace(" ", "_");
string_treeNode2 = _treeNode.Replace("-","_") ;
After that _treeNode2 still has the darn -.
I cant believe this is a bug&weird. Ive googled and no help.
What am I missing here?
I have the following string:
string _node = Individual_Program__Serio
I use the following C#
_node.Replace(-,_).
I am trying to replace the dash with an underscore. After the code executes, it is still a dash!!!
Any suggestions?
I reply back:
Heres your answer&
protected void Page_Load(object sender, EventArgs e)
{
string myNode=
@"Individual_Program__Ser
Label1.Text=myNode;
myNode=myNode.Replace("_",
Label2.Text=myNode;
}
He says:
Im not using ASP. This is in my code generator.
Its maddening& this doesnt work:
string _treeNode = ri.treeNodeName.Replace(" ", "_");
string_treeNode2 = _treeNode.Replace("-","_")
After that _treeNode2 still has the darn -.
I cant believe this is a bug&weird. Ive googled and no help.
myNode.Replace('_','-'). try single quotes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Another email from him. I think...aphillips might be on the right track.
Interesting, this works:
string test = "hello-has_Dash";
test = test.Replace("-","_");
but this doesnt work:
string test = "Program__Serious_Inciden ts_Sorted_ by_Inciden t";
test = test.Replace("-","_");
Is the dash different in those two?!
Interesting, this works:
string test = "hello-has_Dash";
test = test.Replace("-","_");
but this doesnt work:
string test = "Program__Serious_Inciden
test = test.Replace("-","_");
Is the dash different in those two?!
ASKER
Hmm, I think the square thingy might be the cause of the problem. I need to check...
ASKER
Yeah, it was not an ASCII standard format.