What if IEnumerable<string> returns just one string

cesarskunk

New Member
I'm doing a simple Linq query on an XML file\[code\]IEnumerable<string> value = http://stackoverflow.com/questions/11396551/from item in myFile.Descendants("ProductName") select (string)item;\[/code\]Normally (If I have more than one row) I can iterate using a foreach loop :\[code\]foreach (string str in value){ Console.WriteLine(str);}\[/code\]But what if I'm sure that I have just one item, And my method signature is :\[code\]public string getValue(){ return ?;}\[/code\]What should I return (If I want to remove the foreach loop) ?
 
Back
Top