不能在C#中隐式地将类型'string'转换为'system.collections.arraylist'

时间:2012-10-17 14:37:00

标签: c#

这是我的代码:

XmlNodeList ProjectNode = DOC.GetElementsByTagName("AppBuilderProject");

foreach (XmlNode AllNodes in ProjectNode) 
{
    Project.Titel = AllNodes["Titel"].InnerText; // 1st value from node

    foreach (XmlNode controlsform in Project.Forms) // arraylist Forms
    {
        Project.Forms = controlsform["forms"].InnerText;// error
    }
}

请告诉我如何解决此问题。

1 个答案:

答案 0 :(得分:1)

属性“Project.Forms”显然是类型arraylist和属性(XmlNode).InnerText是字符串

试试这个

if(Project.Forms == null) Project.Forms = new ArrayList();
Project.Forms.Add(controlsform["forms"].InnerText);