2013-01-03 26 views
0

在下面的C#代碼段:無法分配 - 方法組?

static XmlNodeList TSList() 
    // This function returns an XML list of all Documents in the library with a status that needs to be audited. 
    // It uses the URL and Library Name found in the project property settings 
{ 
    CPAS_ListSVC.Lists listService = new CPAS_ListSVC.Lists(); 
    listService.Credentials = System.Net.CredentialCache.DefaultCredentials; 
    listService.Url = Properties.Settings.Default.CPAS_ListService_URL;       //"http://moss.mava.micron.com/FACSEC/mtvfacilities/MTVCONSTRUCTION/CPAS/_vti_bin/lists.asmx"; 
    //System.Xml.XmlNode activeItemData = listService.GetListItems("CPAS_Vendor_Timesheets", "{BD56DAD6-8C4F-4BC8-9848-9293D83F4338}", null, null, "500", null, ""); 
    XmlNode activeItemData = listService.GetListItems(Properties.Settings.Default.Timesheet_Library_Name, Properties.Settings.Default.View_GUID, null, null, "500", null, ""); 
    // Set up the XML documents the listservice will retrieve. 
    XmlDocument doc = new XmlDocument(); 
    string temp = activeItemData.InnerXml.Replace("\ref\ref", ""); 
    doc.LoadXml(temp); 
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); 
    nsmgr.AddNamespace("z", "#RowsetSchema"); 
    nsmgr.AddNamespace("rs", "urn:schemas-microsoft-com:rowset"); 
    TSList = (XmlNodeList) doc.SelectNodes("/rs:data/z:row", nsmgr); 
} 

我得到的錯誤「無法分配給‘TSList’,因爲它是一個‘方法組’......爲什麼

回答

3

它看起來像你將一些VB語法與c#混合。將最後一行更改爲以下內容:

return (XmlNodeList) doc.SelectNodes("/rs:data/z:row", nsmgr); 
+0

是啊,雅抓住了我。 D'oh ....感謝您的幫助!你也是,SLaks! –

9

隨着法明確規定,?你不能分配東西的功能

返回一個值,使用return聲明:

return doc.SelectNodes("/rs:data/z:row", nsmgr);