public List<TaskSoftInfo> ReadSoftDownTaskList()
{
string[] Tid = (string[])Cache.Instance.Read(SoftDownTaskList + "Tid");
object[] IDlist = Cache.Instance.GetMultipleArrayByKeys(Tid);
TaskSoftInfo[] tlist = Array.ConvertAll(IDlist, new Converter<object, TaskSoftInfo>(ObjectToTaskSoftInfo));
List<TaskSoftInfo> list = new List<TaskSoftInfo>(tlist);
return list;
}
}
private TaskSoftInfo ObjectToTaskSoftInfo(object o)
{
return (TaskSoftInfo)o;
}
如果是已经知道的对象类型数组,则更好转换,如下
从string[]转List<string>:
普通浏览复制代码 string[] str = { "1", "2", "3" }; List<string> list = new List<string>(str);
从List<string>转string[]:
普通浏览复制代码 List<string> list = new List<string>(); string[] str = list.ToArray();