c# - Can't get a return value from a foreach loop inside a method -


is a method in my C # finds a node with the name node_name node list the Arg , and returns the value of the node (assuming only one node with such a name). If such a node is not found, then it should return empty string.

  public string get_nodes_value (Aksmelanidiist args, string Nod_nav) {foreach (Aksmelanod Ajiaranodi in args) {if (! Arg_node.HasChildNodes) {If (String.Compare (arg_node.ParentNode.Name, node_name ) == 0) {return arg_node.Value; }} And {get_nodes_value (arg_node.ChildNodes, node_name); }} Return ""; }  

The above code always returns an empty string. What do I remember here?

will be returned to the node recurring invitation, but as long as it is not at the top - Livl that price is just ignored possibly want something like:

  else {string value = get_nodes_value (arg_node.ChildNodes, node_name); If (value! = "") Return value; }  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -