请教:C#里有象Delphi里的TObjectList这样的类吗?(100分)

  • 主题发起人 主题发起人 hycstudio
  • 开始时间 开始时间
H

hycstudio

Unregistered / Unconfirmed
GUEST, unregistred user!
请教:C#里有象Delphi里的TObjectList这样的类吗?
如果有,大概是怎么用的?
大家可怜可怜,我没有分了!谢谢!
 
有,ArrayList.具体请看msdn
using System;
using System.Collections;
public class SamplesArrayList {
public static void Main() {
// Creates and initializes a new ArrayList.
ArrayList myAL = new ArrayList();
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");
// Displays the properties and values of the ArrayList.
Console.WriteLine( "myAL" );
Console.WriteLine( "/tCount: {0}", myAL.Count );
Console.WriteLine( "/tCapacity: {0}", myAL.Capacity );
Console.Write( "/tValues:" );
PrintValues( myAL );
}
public static void PrintValues( IEnumerable myList ) {
System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.Write( "/t{0}", myEnumerator.Current );
Console.WriteLine();
}
}
 
接受答案了.
 
后退
顶部