using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
collclass collcalss = new collclass();
collcalss[3] ="傻子" ;
collcalss[4] ="傻子2" ;
for (int i = 0; i < collcalss.Length; i++)
{
Console.Write("{0} ", collcalss[i]);
}
Console.ReadKey();
}
}
class collclass
{
private string[] temp = new string[5] { "笨猪1", "笨猪2", "笨猪3", "笨猪4", "笨猪5" };
public int Length{
get { return temp.Length; }
}
public string this[int index]{
get{return temp[index];}
set{temp[index] = value;}
}
}
}
效果图:
评论