delegate int IntToInt(int i);
static IntToInt Factorial = (n) => n <= 1 ? 1 : n * Factorial(n - 1);
List< String> strs = new List< String>();
// Add
strs.Add("Aa");
strs.Add("Ba");
strs.Add("Ca");
strs.AddRange(new string[] { "Ab", "Bb", "Cb" });
// Work
strs[0] // Aa
strs.Find(a=>a.StartsWith("A")) // First found in list by Indexing is "Aa"
strs.FindAll(a=>a.StartsWith("A")) // Aa, Ab
strs.Where(a=>a.Contain("A")).ToList(); // Aa, Ba, Ca, Aa
// Remove
strs.RemoveAt(0); // By Index
strs.Remove("Aa"); // By Value
strs.RemoveAll(a=>a.StartsWith("A") && EndsWith("a")); // By Query
XDocument xFile = new XDocument(
new XElement("application",
new XAttribute("appName", Application.ProductName),
new XAttribute("appVersion", Application.ProductVersion),
new XElement("movies",
new XAttribute("AttrA", false),
new XAttribute("AttrB", 1000)),
new XElement("movie",
new XAttribute("name", "A"),
new XAttribute("size", "800x600"),
new XAttribute("url", "http://film.com/a.avi")
),
new XElement("movie",
new XAttribute("name", "B"),
new XAttribute("size", "640x480"),
new XAttribute("url", "http://film.com/b.avi")
)
)
);
xFile.Save("FileName.xml");
List< XElement> xs = XDocument
.Load("http://api.themoviedb.org/2.1/Movie.imdbLookup/en/xml/aba51da40c1f8931aab66cd91178a970/tt0137523")
.Element("OpenSearchDescription")
.Element("movies")
.Element("movie")
.Element("images")
.Elements()
.ToList();
xs
.ForEach(
a =>
{
if(a.Attribute("size").value == "poster" && (a.Attribute("type").Value.ToLower() == "poster" || a.Attribute("type").Value.ToLower() == "backdrop"))
{
// Code Here: a.Attribute("url").value
}
}
);
xs
.FindAll((a.Attribute("type").Value.ToLower() == "poster" || a.Attribute("type").Value.ToLower() == "backdrop") && a.Attribute("size").value == "poster"))
.ForEach(
a =>
{
// Code Here: a.Attribute("url").value
}
);
Recent Comments