<%@ Page Language="c#" %>
<script runat="server">
void Page_Load()
{
message1.Text="";
message1.Text+="<BR />Calling Function 1...";
Function1();
message1.Text+="<BR />Calling Function 2...";
Function2();
message1.Text+="<BR />Calling Function 1...";
Function1();
}
void Function1()
{
string Different =
"<i>Hello I'm the variable Different in Function 1</i>";
message1.Text+= Different;
}
void Function2()
{
string Different =
"<b>Hello I'm the variable Different in Function 2</b>";
message1.Text+= Different;
}
</script>
<html>
<head>
<title>Scope</title>
</head>
<body>
<asp:Label id="message1" runat="server"></asp:Label>
</body>
</html>
<script runat="server">
void Page_Load()
{
message1.Text="";
message1.Text+="<BR />Calling Function 1...";
Function1();
message1.Text+="<BR />Calling Function 2...";
Function2();
message1.Text+="<BR />Calling Function 1...";
Function1();
}
void Function1()
{
string Different =
"<i>Hello I'm the variable Different in Function 1</i>";
message1.Text+= Different;
}
void Function2()
{
string Different =
"<b>Hello I'm the variable Different in Function 2</b>";
message1.Text+= Different;
}
</script>
<html>
<head>
<title>Scope</title>
</head>
<body>
<asp:Label id="message1" runat="server"></asp:Label>
</body>
</html>
此博客展示了一段基于.NET的代码,使用C#语言。在Page_Load函数中依次调用Function1和Function2函数,并将调用信息及函数内定义的字符串变量输出到页面的Label控件上,体现了函数调用和字符串处理。

被折叠的 条评论
为什么被折叠?



