Created
July 29, 2012 08:54
-
-
Save aturgarg/3196816 to your computer and use it in GitHub Desktop.
Linq XML ( string list)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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