I see a lot of questions about how to convert TO lambda syntax and very few of the opposite.
I don't speak C#, could anyone please help me dissect this:
XmlSchema schema = XmlSchema.Read(schemaStream, (s, e) => {Debug.WriteLine("Xml schema validation error : " e.Message);});
How will this line look without using lambda expression?
Thanks.
CodePudding user response:
If you want to translate it back into old-fashioned, pre-=>
C#, you'd do something like:
private void OnValidationError(object sender, ValidationEventArgs args)
{
Debug.WriteLine($@"Xml schema validation error : {args.Message}");
}
and then call the Read method this way:
XmlSchema schema = XmlSchema.Read(schemaStream, OnValidationError);
CodePudding user response:
The best way would be to write a local function:
void Error (object s, ValidationEventArgs e) => Debug.WriteLine("Xml schema validation error : " e.Message);
XmlSchema schema = XmlSchema.Read(schemaStream, Error);