| Input: | IEnumerable<TSource> |
| Lamdbda expression: | TSource => TResult or (TSource,int) => TResult |
| Query syntax: | select projectionExpression |
Select returns the same number of elements as the input.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
string[] names = { "Java", "C#", "Javascript", "SQL", "Oracle", "Python", "C++", "C", "HTML", "CSS" };
IEnumerable<string> query = from n in names select n.ToLower();
foreach(String s in query){
Console.WriteLine(s);
}
}
}
The output:
java
c#
javascript
sql
oracle
python
c++
c
html
cssThe select operator can accept an integer argument as an indexer.
This works only with local queries:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
string[] names = { "Java", "C#", "Javascript", "SQL", "Oracle", "Python", "C++", "C", "HTML", "CSS" };
IEnumerable<string> query = names.Select((s, i) => i + "=" + s);
foreach(String s in query){
Console.WriteLine(s);
}
}
}
The output:
0=Java
1=C#
2=Javascript
3=SQL
4=Oracle
5=Python
6=C++
7=C
8=HTML
9=CSS| w__w_w__.___j___a__v__a_2__s_.___com___ | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |