如何创建用户定义类的ArrayList

时间:2011-07-27 06:14:21

标签: c#

我有一个类假设功能

我正在写这样的代码

class FunctionsList
{

  public ArrayList<Function> functionList // this resuls in error while in Java i have done same
  { 
     get;
     set;
  }
}

while Function class is defined below

public class Function 
{
   public String Name
   {
         get; set;
   }

   public String Signature
   {
         get; set;
   }
}

我在C#中做错了告诉

2 个答案:

答案 0 :(得分:4)

我在.NET中需要使用List<Function>。类ArrayList仅存在于非通用版本中,基本上已被List<T>取代。

答案 1 :(得分:1)

在C#中,ArrayList是一个对象数组,没有泛型类。

您可以考虑使用其他通用容器

List<T>, 
Collection<T> 
HashSet<T>
相关问题