现在的位置: 首页 > 综合 > 正文

C#.NET中的集合

2013年01月13日 ⁄ 综合 ⁄ 共 616字 ⁄ 字号 评论关闭
/*
 * Created by SharpDevelop.
 * User: noo
 * Date: 2009-8-17
 * Time: 18:57
 * 
 * 集合
 
*/

using System ;
class collectionA
{
    
private string str;
    
public collectionA(string STR)
    {
        str
=STR;
    }
    
public void outoput()
    {
        Console.WriteLine (
"我是"+str);
    }
}
class Test
{
    
static void Main()
    {
        collectionA[] arr
=new collectionA[5];//定义一个类型为collectionA的实例数组arr
        arr[0]=new collectionA ("张三");//实例化
        arr[1]=new collectionA ("李四");
        arr[
2]=new collectionA ("王五");
        arr[
0].outoput ();//输出"我是张三"
        arr[1].outoput ();//输出"我是李四"
        arr[2].outoput ();//输出"我是王五"
    }
}

抱歉!评论已关闭.