Category archive: c#

Linq to XML get attribute

Linq to XML simple get attribute from node statement up vote 2 down vote favorite Ok so heres the code snippet. XDocument themes = XDocument.Load(HttpContext.Current.Server.MapPath(“~/Models/Themes.xml”)); string result = “”; var childType = from t in themes.Descendants() where t.Attribute(“name”).Value.Equals(theme) select new { value = t.Attribute(“type”).Value }; foreach (var t in childType) { result += t.value; }…

Understand Lambda Expressions

Understand Lambda Expressions 25 Mar 2013 What is a Lambda Expression? A lambda expression is an anonymous function and it is mostly used to create delegates in LINQ. Simply put, it’s a method without a declaration, i.e., access modifier, return value declaration, and name. Why do we need lambda expressions? (Why would we need to write a method without…

Menu