/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/visual-basic/programming-guide/concepts/linq/snippets/OtherExtensions.vb
38 строк
1 KB
Bill Wagner
update sample for LINQ how to (#20312)
28 авг 2020, 22:25
Не верифицирован
28 авг 2020, 22:25
83bdd1f
Код
Авторство
О чём код?
Imports System.Runtime.CompilerServices Module OtherExtensions ' <IntOverload> ' Integer overload <Extension()> Function Median(ByVal source As IEnumerable(Of Integer)) As Double Return Aggregate num In source Select CDbl(num) Into med = Median() End Function ' </IntOverload> ' <GenericOverload> ' Generic overload. <Extension()> Function Median(Of T)(ByVal source As IEnumerable(Of T), ByVal selector As Func(Of T, Double)) As Double Return Aggregate num In source Select selector(num) Into med = Median() End Function ' </GenericOverload> ' <SequenceElement> ' Extension method for the IEnumerable(of T) interface. ' The method returns every other element of a sequence. <Extension()> Iterator Function AlternateElements(Of T)( ByVal source As IEnumerable(Of T) ) As IEnumerable(Of T) Dim i = 0 For Each element In source If (i Mod 2 = 0) Then Yield element End If i = i + 1 Next End Function ' </SequenceElement> End Module