c# - Use of an unassigned local string variable -
this question has answer here:
im trying set function read values xml file
the function following..
public string xmlreadvalue(string filepath, string element, string subelement) { xmldocument xml = new xmldocument(); xml.load(filepath); xmlnodelist elements = xml.selectnodes("//" + element); string valuee; foreach (xmlnode elemente in elements) { valuee = elemente.selectsinglenode(subelement).innertext; } return valuee; }
when return value valuee
says use of unassigned local variable 'valuee'
what doing wrong?
if elements
empty never affect value valuee
.
you should initialize :
string valuee = "";
Comments
Post a Comment