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

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -