update xml using linq in c#

I am a .net beginner. I am trying to update my xml file using linq. I got stuck at the very first point of it i.e i cant grab the value from xml file using linq.These are the controls I am using in my code:\[code\]cbBrandName -- comboboxcbProduct -- comboboxtxtQuantity -- TextBox\[/code\]I am trying the below code: \[code\]XElement doc = XElement.Load(@"..\..\stock.xml");string quantity = doc.Descendants("quantity") .Select(y => y.Element("quantity").Value.Equals(txtQuantity.Text))/*red scribbles to 'Element' in 'where'*/ .Where(x => x.Element("productname").Value.Equals(cbProduct.Text) && x.Element("brandname").Value.Equals(cbBrandName.Text)).ToString();MessageBox.Show(quantity.ToString());\[/code\]here I am trying to store the "quantity" value in \[code\]quantity\[/code\] string so that i can manipulate it later and then again update to my xml file. when I make \[code\].select\[/code\] as comment it isn't showing any errors but when i run it, instead of text it is showing some \[code\]system.linq.Enumerable + .....\[/code\] in the MessageBox.EDIT:
XzCSM.png
when i give \[code\].toString()\[/code\] at the end it. It is showing error -- "Object reference not set to an instance of an object." when i run it.Please help
Thanks in Advance.
 
Back
Top