Skip to content

Instantly share code, notes, and snippets.

@ViIvanov
Last active August 29, 2015 14:01
Show Gist options
  • Save ViIvanov/64530a70d3aa6a0821a3 to your computer and use it in GitHub Desktop.
Save ViIvanov/64530a70d3aa6a0821a3 to your computer and use it in GitHub Desktop.
static class C
{
static object M0<T>(IEnumerable<T> source) {
// linq с новой строки
var e1 =
from item in source
select item.ToString();
return e1;
}
static object M1<T>(IEnumerable<T> source) {
// а для return исключение
return from item in source
select item.ToString();
}
static object M2<T>(IEnumerable<T> source) {
var e1 = (
from item in source
select item.ToString()
).ToList();
var e2 = e1.Any()
? (from item in e1
// A few-lines linq here…
select result).ToArray()
: new T[0];
return e2;
}
static object M3<T>(IEnumerable<T> source) {
// Specific join with "on" on the same indent
return from item in source
join xxx in
from qqq in Enumerable.Range(1, 10)
select qqq.ToString()
on item.ToString() equals xxx.ToString()
select item.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment