在研究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