现在的位置: 首页 > 综合 > 正文

.Trim()应注意的问题

2013年02月16日 ⁄ 综合 ⁄ 共 265字 ⁄ 字号 评论关闭

 

使用.Trim()应注意的问题:

请看以下代码


    
protected void Button1_Click(object sender, EventArgs e)
    {
        
string str = "abc ";
        str.Trim();
        TextBox1.Text 
= str;

        string str2 = "abc ";
        TextBox2.Text 
= str2.Trim();
    }

执行结果:

TextBox1里仍然有空格
TextBox2里没有空格

抱歉!评论已关闭.