出现的C#问题(100分)

hiweiyi2000 2004-10-14 05:05:19
<script Runat="Server">
public string Word;

void Repeat(int intNumTimes)
{
int intCounter;
for(intCounter=0;intCounter<intNumTimes-1;intCounter++)
{
Response.Write(Word);
}
}

</script>



“/s”应用程序中的服务器错误。
--------------------------------------------------------------------------------

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: BC30183: 关键字作为标识符无效。

源错误:



行 1: <script Runat="Server">
行 2: public string Word;
行 3:
行 4: void Repeat(int intNumTimes)


源文件: C:\Inetpub\wwwroot\bhzl\news_images\WordRepeater.ascx 行: 2
...全文
93 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2004-10-14
  • 打赏
  • 举报
回复
<%@page language="c#"%>
<script runat=server>
public string Word;
void Page_Load(Object sender, EventArgs e)
{
Word="x";
Repeat(5);
}
void Repeat(int intNumTimes)
{
int intCounter;
for(intCounter=0;intCounter<intNumTimes-1;intCounter++)
{
Response.Write(Word);
}
}
</script>
<form runat=server>
</form>
孟子E章 2004-10-14
  • 打赏
  • 举报
回复
<script language=c# runat=server>
public string Word;
void Page_Load(Object sender, EventArgs e)
{
Word="x";
Repeat(5);
}
void Repeat(int intNumTimes)
{ int intCounter;
for(intCounter=0;intCounter<intNumTimes-1;intCounter++)
{
Response.Write(Word);
}
}
</script>
<form runat=server>
</form>
yufeng777 2004-10-14
  • 打赏
  • 举报
回复
Word是关键字,换一个变量名
wangsaokui 2004-10-14
  • 打赏
  • 举报
回复
不知道了,做了测试,我这里是可以的。
public string Word;
是否应用了别的dll,所以Word成保留字了。
qingyun1020 2004-10-14
  • 打赏
  • 举报
回复
给你顶
zyw2833 2004-10-14
  • 打赏
  • 举报
回复
Word是关键字
shenanigan 2004-10-14
  • 打赏
  • 举报
回复
感觉Word是关键字?
wangsaokui 2004-10-14
  • 打赏
  • 举报
回复
不对,你应该把这个字符串的定义放到一个类中
like:
public class a
{
public string Word;
....
}
wangdequan1024 2004-10-14
  • 打赏
  • 举报
回复
改成这样
<script Runat="Server">
public string strWord;

void Repeat(int intNumTimes)
{
int intCounter;
for(intCounter=0;intCounter<intNumTimes-1;intCounter++)
{
Response.Write(strWord);
}
}

</script>
wangsaokui 2004-10-14
  • 打赏
  • 举报
回复
public string Word;
=====>
public string _Word;

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧