I have a problem with my code in c# if someone could help resolve my problem.
In a function I am parsing a Xml file and saving it to a struct.
Then I try to retreive some info from said struct with a specific node id and my code fails with
"Cannot use ref or out parameter 'c' inside an anonymous method, lambda expression, or query expression"
Here is my code:
public void XmlParser(ref Point a, ref Point b, ref Point c)
{
XDocument xdoc = XDocument.Load(XmlDirPath);
var coordinates = from r in xdoc.Descendants("move")
where int.Parse(r.Attribute("id").Value) == c.NodeID // !! here is the error !!
select new
{
X = r.Element("x").Value,
Y = r.Element("y").Value,
Z = r.Element("z").Value,
nID = r.Attribute("id").Value
};
foreach (var r in coordinates)
{
c.x = float.Parse(r.X1, CultureInfo.InvariantCulture);
c.y = float.Parse(r.Y1, CultureInfo.InvariantCulture);
c.z = float.Parse(r.Z1, CultureInfo.InvariantCulture);
c.NodeID = Convert.ToInt16(r.nID);
}
}
public struct Point
{
public float x;
public float y;
public float z;
public int NodeID;
}