找不到类型或命名空间名称“StringBuilder”(是否缺少 using 指令或程序集引用?)

来源:百度知道 编辑:UC知道 时间:2024/05/23 01:24:09
本人是编程的初学者,
用VS2003照一本书写最简单的代码,没想到一开始就有问题:

D:\Inetpub\wwwroot\Hello\Hello.aspx.cs(53): 找不到类型或命名空间名称“StringBuilder”(是否缺少 using 指令或程序集引用?)

D:\Inetpub\wwwroot\Hello\Hello.aspx.cs(54): 找不到类型或命名空间名称“StrScript”(是否缺少 using 指令或程序集引用?)

D:\Inetpub\wwwroot\Hello\Hello.aspx.cs(64): 找不到类型或命名空间名称“StrScript”(是否缺少 using 指令或程序集引用?)

D:\Inetpub\wwwroot\Hello\Hello.aspx.cs(65): 找不到类型或命名空间名称“StrScript”(是否缺少 using 指令或程序集引用?)

D:\Inetpub\wwwroot\Hello\Hello.aspx.cs(66): 找不到类型或命名空间名称“StrScript”(是否缺少 using 指令或程序集引用?)

代码是这样的:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Hello01
{
/// &l

把你的using改为:
using System;

//add this for stringbuilder
using System.Text;

using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

----------------------------

另外,你的代码中
if(this.t.Text != null)
{
str = this.tbName.Text.Trim() + ",你好!";
}

中的t,没有定义,看看是不是差控件

给你说一种简单的方法
private void btHello_Click(object sender, System.EventArgs e)
{
if(this.t.Text != null)
{
str = this.tbName.Text.Trim() + ",你好!";
}
else
{
Response.Write("<script>alert('姓名不能为空!')</script>");
}
}
只写这几句就可以了,别的全不要了
这样就能验证了简单又好用。
希望能帮到你。

一、加引用
using System.Text;
二、把St