C# 编译器错误:CS1026:)应为
当我试图编译代码时,编译器会给出以下错误: CS1026:)预期C# 编译器错误:CS1026:)应为,c#,C#,当我试图编译代码时,编译器会给出以下错误: CS1026:)预期 使用(XmlReader=XmlReader.Create(newstreamreader(myFile.InputStream))) { List blogPosts=新列表(); blogPosts=reader.ReadContentAsAsync(列表); } 我的代码中似乎没有缺少右括号。那么错误在哪里呢?下一行的语法无效 ReadContentAsAsync(List List<BlogPosts>);
使用(XmlReader=XmlReader.Create(newstreamreader(myFile.InputStream)))
{
List blogPosts=新列表();
blogPosts=reader.ReadContentAsAsync(列表);
}
我的代码中似乎没有缺少右括号。那么错误在哪里呢?下一行的语法无效
ReadContentAsAsync(List List<BlogPosts>);
as
blogPosts
属于List
类型。如果还需要解析名称空间,请为第二个参数传递名称空间解析程序,而不是null
。可能需要更改:
blogPosts = reader.ReadContentAsAsync(List List<BlogPosts>);
blogPosts=reader.ReadContentAsAsync(列表);
进入:
blogPosts=reader.ReadContentAsAsync(typeof(List),null)//将null更改为任何必要的IXmlNamespaceResolver
接收
类型
作为输入参数。列表
。ReadContentAsAsync(列表)?但您将编译器与ReadContentAsAsync(列表)混淆代码>这一个<代码>列表)
blogPosts=reader.ReadContentAsAsync(typeof(List))代码>这不是一个答案,只是一个评论。您没有提供任何问题的解决方案我倾向于不同意您的观点,因为问题是“为什么我会遇到编译器错误xyz。错误在哪里?”-答案是:语法无效。但我还是要编辑答案。
blogPosts = reader.ReadContentAsAsync(typeof(List<BlogPosts>), null);
blogPosts = reader.ReadContentAsAsync(List List<BlogPosts>);
blogPosts = reader.ReadContentAsAsync(typeof(List<BlogPosts>), null); //change null to any necessary IXmlNamespaceResolver