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' は 'メソッド グループ' であるため、'TSList' に割り当てることができません...なぜですか?」というエラーが表示されます。

4

2 に答える 2

9

メソッドが明確に述べているように、関数に何かを割り当てることはできません。

値を返すには、次のreturnステートメントを使用します。

return doc.SelectNodes("/rs:data/z:row", nsmgr);
于 2013-01-03T19:51:37.913 に答える
3

いくつかのVB構文をc#と混合しているようです。最後の行を次のように変更します。

return (XmlNodeList) doc.SelectNodes("/rs:data/z:row", nsmgr);
于 2013-01-03T19:53:12.047 に答える