Skip to content

Instantly share code, notes, and snippets.

@aturgarg
Created July 29, 2012 08:54
Show Gist options
  • Save aturgarg/3196816 to your computer and use it in GitHub Desktop.
Save aturgarg/3196816 to your computer and use it in GitHub Desktop.
Linq XML ( string list)
class Program
{
static void Main(string[] args)
{
Program p = new Program();
Console.WriteLine(p.linqStringList());
Console.ReadLine();
}
protected string linqStringList()
{
try
{
List<string> lst = new List<string>();
for (int i = 0; i < 10; i++)
{
lst.Add((i + 1).ToString());
}
XElement xe = new XElement("XMLs",
from str in lst
select (new XElement("Tag",str)
));
return xe.ToString();
}
catch
{ }
return "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment