我得到一个类型或命名空间名称'listcolumns'找不到(你错过了使用指令或程序集引用吗?)

时间:2015-06-08 16:38:37

标签: generics sharepoint-2010 .net-3.5

好的,所以我有这个代码可以不断抛出上面的错误。我真的把头发拉出来试图找出来。

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Collections.Generic;
using System.Collections;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;


namespace VarianceList.WebPart1
{
[ToolboxItemAttribute(false)]
public class WebPart1 : WebPart
{
    private class ListColumns
    {
        public String li_requestDate { get; set; }
        public String li_paymentAmount { get; set; }
        public String li_payeeName { get; set; }
    }

这是错误开始的地方:

private List<listcolumns> ReadFromList()
{
List<listcolumns> lcList = new List<listcolumns>();

using (SPSite site = new SPSite("http://ServerName"))
{
    using (SPWeb web = site.OpenWeb("locationOfWeb"))
    {
        SPList list = web.Lists["ListName"];
        SPListItemCollection SpListColl = list.Items;
        foreach (SPListItem item in SpListColl)
        {
            ListColumns lc = new ListColumns();
            if (null != item["Title"])
            {
                if (!(String.IsNullOrEmpty(item["RequestDate"].ToString())))
                {
                    lc.li_requestDate = item["RequestDate"].ToString();
                }
                // . . . and so forth

另外,在这里我收到以下错误:无法从'VarianceList.WebPart1.WebPart1.ListColumns'转换为'listcolumns'

lcList.Add(lc);
            }
        }
    } // using (SPWeb
} // using (SPSite  
return lcList;
}        }
}

1 个答案:

答案 0 :(得分:0)

C#是一种区分大小写的语言。您定义了一个班级ListColumns,但您将其称为listcolumns

那不行。