C# 从arraylist获取数据结构的值
我有一个arraylist,里面有数据结构 我在试图找出如何取回这些值并在表中显示它们时遇到了问题 谢谢 这是我的结构C# 从arraylist获取数据结构的值,c#,asp.net,visual-studio,C#,Asp.net,Visual Studio,我有一个arraylist,里面有数据结构 我在试图找出如何取回这些值并在表中显示它们时遇到了问题 谢谢 这是我的结构 public BackupSpecEntry(string Path, string InclExcl, byte InclExclFlags, bool IndexContents, int ServerBackupSpecId, int Freq, int Retention) { path = Path; inc
public BackupSpecEntry(string Path, string InclExcl, byte InclExclFlags, bool IndexContents,
int ServerBackupSpecId, int Freq, int Retention)
{
path = Path;
inclExcl = InclExcl;
inclExclFlags = InclExclFlags;
indexContents = IndexContents;
serverBackupSpecId = ServerBackupSpecId;
freq = Freq;
retention = Retention;
}
ArrayList
不是强类型的,因此无论何时拉出项,都必须将其转换回自定义对象类型。然后您应该能够访问它的属性。我假设通过表和Asp.net属性,您指的是DataGrid、GridView或DetailsView。这是正确的吗。假设是:读取数据绑定和自定义对象。如果你想找的话,网上有很多关于这个主题的信息 使用ArrayList时,您需要对其进行施放
ArrayList list = new ArrayLIst();
: your code
BackupSpecEntry entry = (BackupSpecEntry)list[0];
但是,使用带有C#的泛型,您可以创建一个模板列表:
List<BackupSpecEntry> list = new List<BackupSpecEntry>();
: your fill list code
BackupSpecEntry entry = list[0];
List List=新列表();
:您的填写列表代码
BackupSpecEntry条目=列表[0];
你能给我举个例子吗。。。我不能跟随。。。谢谢你这么快的答复这是个相当模糊的问题。您能否首先展示一下如何将结构“放入ArrayList
?