在看C#的SharpICTCLAS,wordResult是一个类,总感觉怪怪的,自己写了个小类测试一下。代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace test
{
class Program
{
static void Main(string[] args)
{
ArrayList arrlist = new ArrayList();
User user1 = new User("dahan",20,"shandong");
User user2 = new User("xiaoshan",22,"weifang");
arrlist.Add(user1);
arrlist.Add(user2);
List<User> userList = new List<User>();
userList.Add(user1);
userList.Add(user2);
for (int i = 0; i < userList.Count;i++ )
Console.WriteLine("{0}{1}{2}", userList[i].UserName,userList[i].Age,userList[i].Address);
Console.WriteLine("==========================================");
for (int i = 0; i < arrlist.Count; i++)
Console.WriteLine(((User)arrlist[i]).UserName);
Console.WriteLine("==========================================");
List<User []> listUser = new List<User[]> ();
User[] u1 = new User[2];
u1[0] = user1;
u1[1] = user2;
listUser.Add(u1);
Console.ReadKey();
}
}
class User
{
private string userName;
private int age;
private string address;
public string UserName
{
set { userName = value; }
get { return userName; }
}
public int Age
{
set { age = value; }
get { return age; }
}
public string Address
{
set { address = value; }
get { return address; }
}
public User(string userName,int age,string address)
{
this.userName = userName;
this.age = age;
this.address = address;
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace test
{
class Program
{
static void Main(string[] args)
{
ArrayList arrlist = new ArrayList();
User user1 = new User("dahan",20,"shandong");
User user2 = new User("xiaoshan",22,"weifang");
arrlist.Add(user1);
arrlist.Add(user2);
List<User> userList = new List<User>();
userList.Add(user1);
userList.Add(user2);
for (int i = 0; i < userList.Count;i++ )
Console.WriteLine("{0}{1}{2}", userList[i].UserName,userList[i].Age,userList[i].Address);
Console.WriteLine("==========================================");
for (int i = 0; i < arrlist.Count; i++)
Console.WriteLine(((User)arrlist[i]).UserName);
Console.WriteLine("==========================================");
List<User []> listUser = new List<User[]> ();
User[] u1 = new User[2];
u1[0] = user1;
u1[1] = user2;
listUser.Add(u1);
Console.ReadKey();
}
}
class User
{
private string userName;
private int age;
private string address;
public string UserName
{
set { userName = value; }
get { return userName; }
}
public int Age
{
set { age = value; }
get { return age; }
}
public string Address
{
set { address = value; }
get { return address; }
}
public User(string userName,int age,string address)
{
this.userName = userName;
this.age = age;
this.address = address;
}
}
}
也没什么需要解释得了。