Given an collection as -8, -7, 6, 0, 7, -1, 6. The objective is to find the summation of negative numbers from the collection of numbers. The below program will do so
Imports System.Collections.Generic
Imports System.Linq
Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())
Console.WriteLine(New List(Of Integer)() From { _
-8, _
-7, _
6, _
0, _
7, _
-1, _
6 _
}.OrderBy(Function(o) o).TakeWhile(Function(t) t < 0).Sum())
Console.ReadKey()
End Sub
End Class
End Namespace
Output: -16