.NET Framework类库由命名空间组成,每个命名空间都包含可在程序中使用的类型:类、结构、枚举、委托和接口。
大多数C#程序由一个命令节开始,该节列出应用程序将会频繁使用的命名空间,避免程序员在每次使用其中包含的方法时都要指定完全限定的名称。
2.数组
推荐使用(SharpDevelop)
例子:
using System;
class SetArray
{
public void PrintArr(int ArrLength)
{
int [] arr=new int[ArrLength];
for(int i=0;i<arr.Length;i++)
arr[i]=i;
Console.WriteLine("输出结果:");
for(int i=0;i<arr.Length;i++)
Console.WriteLine("arr[{0}]=[1]",i,arr[i]); //将所有元素打印出来
}
}
class Test
{
static void Main()
{
SetArray arr=new SetArray();
int i=1;
while(i>0)
{
Console.WriteLine("请输入一个值:");
i=Int32.Parse(Console.ReadLine()); //同ReadLine接受数值,ReadLine返回的是一个字符,所以转换成数值赋给“i”
arr.PrintArr(i); //把取到的用户数值给SetArray类中的PrintArr过程
}
}
}