I had to split up my function with a if but the function does not allow returning values defined in the if()
if (nodeHeader == "SUBJ:"){
XmlNode T1 = d.CreateNode(XmlNodeType.Element, "ap", "Topic", "x");
} else {
XmlNode T1 = d.CreateNode(XmlNodeType.Element, "ap", "NotesGroup", "x");
}
Return T1;
I hope somebody can help me.
Pascal.

1 answers
The reason this code doesn't work is that you have distinct variables both called T1 which are local to the 'if' and 'else' blocks but are not accessible outside those blocks.
To make it work, I'd refactor it as follows:
You could also eliminate the T1 variable with:
if (nodeHeader == "SUBJ:"){return d.CreateNode(XmlNodeType.Element, "ap", "Topic", "x");
} else {
return d.CreateNode(XmlNodeType.Element, "ap", "NotesGroup", "x");
}
answered one year ago by:
17279