变量范围学习案例

来源:岁月联盟 编辑:zhu 时间:2004-09-13
using System;
public class ScopeTest
{
public static int Main()
{
for(int i=0;i<10;i++)
{
Console.WriteLine(i);
} //i goes out of scope here

//u should can be declare a variable named i again,because
//there's no other variable with that name in scope
for(int i=9;i>=0;i--)
{
Console.WriteLine(i);
} //i goes out of scope here
return 0;
}
}