小编And*_*y12的帖子

如何从Arraylist中获取数据

所以在之前的问题中,我问我如何将多个数组列表合并到一个数组列表中.

这个答案有效(也在下面列出).但是,我在记录中遇到问题.如何从这个多维arraylist中获取数据.例如,如果我想获得地址,该怎么办?

ArrayList Names = new ArrayList(); 
ArrayList Phone = new ArrayList(); 
ArrayList Address = new ArrayList(); 
ArrayList res = new ArrayList();  
for(int i=0; i<Names.Count; i++) 
{   
  res.Add(new string[]{Names[i].ToString(), Phone[i].ToString(), Address[i].ToString()}); 
} 
Run Code Online (Sandbox Code Playgroud)

c# arraylist

1
推荐指数
1
解决办法
8398
查看次数

使用set和get属性读取注册表

我不确定我在这里做错了什么.我有一个类来创建一些reg键值,我继续得到类型转换错误.我传了钥匙的名字.键的值是int.哪个也应该是返回值.

我继续得到这个错误

无法将类型'string'隐式转换为int

在以下位置:

rValue = (string)myKey.GetValue("DebugLog");
&set { DebugLog = getDebugLog(value);}
Run Code Online (Sandbox Code Playgroud)

请注意c#

private int DebugLog;

private int getDebugLog(String name)
{
    int rValue;
    myKey = Registry.LocalMachine.OpenSubKey(regKey + name, false);
    rValue = (string)myKey.GetValue("DebugLog");
    return rValue;
}

public int debugLog
{
    get { return DebugLog; }
    set { DebugLog = getDebugLog(value);}
}
Run Code Online (Sandbox Code Playgroud)

c# registry

0
推荐指数
1
解决办法
512
查看次数

标签 统计

c# ×2

arraylist ×1

registry ×1