在研究XSD验证时通过this进行了读取。遇到这段代码。While循环语法说明
private static IEnumerable<ValidationEventArgs> RunValidation(string inputXml, bool includeHelperSchema)
{
var schemaSet = new XmlSchemaSet();
schemaSet.Add(schemaUnderTest);
if (includeHelperSchema)
{
schemaSet.Add(helperSchema);
}
var readerSettings = new XmlReaderSettings()
{
Schemas = schemaSet,
ValidationType = ValidationType.Schema,
ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings,
};
var events = new List<ValidationEventArgs>();
readerSettings.ValidationEventHandler += (s, e) => { events.Add(e); };
using (var reader = XmlReader.Create(new StringReader(inputXml), readerSettings))
{
while (reader.Read())
;
}
return events;
}
可能有人请向我解释什么是分号的目的,在这里被放在什么位置?
while (reader.Read())
;
删除给出错误“Invalid expression term '}' ; expected
”。
请指出行。 – mmushtaq
更新了问题 – Akshatha