在vb中Replace函数能够使用,但在C#中好象有问题,但在SDK的帮助文件中确实有Replace函数: [Visual Basic] Overloads Public Shared Function Replace( _ ByVal input As String, _ ByVal pattern As String, _ ByVal replacement As String _ ) As String ----------------------------[C#] public static string Replace( string input, string pattern, string replacement );我试过一个例子: vb中: sub Button1_click(Sender as object,e as EventArgs) label1.Tex=Replace(TextArea.Text,"\n", "<BR>"); end sub 能通过 c#中: public void Button_click(object sender,EventArgs e) { Label1.Text =Replace(TextArea.Text, "\n", "<BR>"); } 出现: " The name 'Replace' does not exist in the class or namespace " 的错误
改为 select ...,Replace(myA5,'\n','<br>'),... from ...
sql语句
select ...,Replace(myA5,'\n','<br>') as myA5,...
"System.Data.OleDb.OleDbException: 表达式中 'Replace' 函数未定义"
的错误,望指教
这样吧
把TextBox1.Text存进数据库时处理,
TextBox1.Text.Replace("\n","<br>").Replace(" ","  ")
替换掉换行与空格
DataBinder.Eval(Container.DataItem, "myA5") =>DataBinder.Eval(Container.DataItem, "myA5").Replace("\n","<br>")
DataBinder.Eval(Container.DataItem,"myA5","{0}").Replace("\n","<br>").Replace(" ","  ")
[Visual Basic]
Overloads Public Shared Function Replace( _
ByVal input As String, _
ByVal pattern As String, _
ByVal replacement As String _
) As String
----------------------------[C#]
public static string Replace(
string input,
string pattern,
string replacement
);我试过一个例子:
vb中:
sub Button1_click(Sender as object,e as EventArgs)
label1.Tex=Replace(TextArea.Text,"\n", "<BR>");
end sub
能通过
c#中:
public void Button_click(object sender,EventArgs e)
{
Label1.Text =Replace(TextArea.Text, "\n", "<BR>");
}
出现:
" The name 'Replace' does not exist in the class or namespace " 的错误
将TextArea.Text全改为TextArea.Value
所以应该为Label1.Text=Label1.Text.Replace("","")