-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtensionMethods.cs
38 lines (33 loc) · 1.13 KB
/
ExtensionMethods.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Text;
namespace DelegatesLambdasEvents
{
public static class ExtensionMethods
{
public static DateTime Combine(this DateTime datePart, DateTime timePart)
{
return new DateTime(datePart.Year, datePart.Month, datePart.Day, timePart.Hour, timePart.Minute, timePart.Second);
}
public static IEnumerable<int> Where(this IEnumerable<int> input, Func<int,bool> predicate)
{
foreach (int t in input)
if (predicate(t))
{
Console.WriteLine("GOT IT !");
yield return t;
}
}
public static IEnumerable<T> Where<T>(this IEnumerable<T> items, Func<T,bool> gauntlet)
{
foreach (T item in items)
if (gauntlet(item))
yield return item;
}
//public static IEnumerable<T> Select<T,R>(this IEnumerable<T> items, Func<T,R> transform)
//{
// foreach(T item in items)
// yield return transform
//}
}
}