In this example we will use Anonymous Types in Linq..
Let's See the Example:
We are converting each string in strWords to its Lower and Upper Case and storing it to a new datatype with Two Properties :
1 . Lower
2. Upper
It's Just like a structure and with each string in strWords we are creating a object of this structure containing the Lower and Upper Case of the respected strWords.
Let's See the Example:
string[] strWords = { "oNe", "TwO", "tHrEe" }; var words = from w in strWords select new { Upper = w.ToUpper(), Lower = w.ToLower() }; foreach (var t in words) { Console.WriteLine(t.Lower + " " + t.Upper); }
We are converting each string in strWords to its Lower and Upper Case and storing it to a new datatype with Two Properties :
1 . Lower
2. Upper
It's Just like a structure and with each string in strWords we are creating a object of this structure containing the Lower and Upper Case of the respected strWords.
Output:
one ONE
two TWO
three THREE
0 comments:
Post a Comment