Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

Am translating VB code to C# as described below and have an error.

below is the VB code

XML
newcell = New TableCell()
newcell.ApplyStyle(list_row_cell_style)
newcell.Wrap = "false"
newcell.HorizontalAlign = HorizontalAlign.Center
newcell.Text = "<a href=?delete_set=" & rs.Item("SetID") & " onClick=""return confirm('Delete this set (" & Replace(rs.Item("set_name"),"'", "\'") & ")?  All content information will be lost.')""><img src=../images/icon-delete.gif border=0 alt=""delete""></a>"
newrow.Cells.Add(newcell)



below is the C# code

XML
newcell = new TableCell();
            newcell.ApplyStyle(list_row_cell_style);
            newcell.Wrap = false;
            newcell.HorizontalAlign = HorizontalAlign.Center;
            newcell.Text = "<a href=?delete_set=" + rs["SetID"] + " onClick=\"return confirm('Delete this set (" + String.Replace(rs["set_name"].ToString(), "'", "\\'" + ")?  All content information will be lost.')\"><img src=../images/icon-delete.gif border=0 alt=\"delete\"></a>";
            newrow.Cells.Add(newcell);


Error:
newcell.Text = "error name:
No Overload for method 'Replace' takes 3 arguments

Please help me out
Posted
Comments
[no name] 11-Jun-15 7:09am    
If you do not know how to use a method of a class, it's really helpful to read the documentation... https://msdn.microsoft.com/en-us/library/aa904304(v=vs.71).aspx

1 solution

Try it like this :
C#
rs["set_name"].ToString.Replace( "'", "\\'") 


Sometimes it is very much better to build up not so long code-lines ...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900