Values are not placed in my variable by foreach, what do I do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.IO;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace Tabela
{
[Activity (Label = "Result")]
public class Result : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
string s, e, n, v;
StreamReader strm = new StreamReader(Assets.Open("tabela.xml"));
XDocument xd = XDocument.Load(strm);
var q = from b in xd.Descendants("elemento")
where Convert.ToString(b.Element("simbolo")) == "H"
select new
{
simbolo = (string)b.Element("simbolo").Value,
elemento = (string)b.Element("elemento").Value,
nAtomic = (string)b.Element("nAtomic").Value,
valencia = (string)b.Element("valencia").Value
};
TextView es = FindViewById<TextView> (Resource.Id.tl);
foreach (var a in q)
{
s = a.simbolo;
e = a.elemento;
n = a.nAtomic;
v = (string)a.valencia;
}
es.Text = s;
SetContentView (Resource.Layout.Resultado);
}
}
}