C
Chris Dunaway
I use the following the C# Linq expression to find a list of processes
with unique names and it returned the results I
expected. However, curiously, the VB version did not seem to work.
Can anyone correct my VB version so that it returns the same results
as the C# version?
C# version works (new keyword used so data binding will work
correctly):
var uniqueProcs = Process.GetProcesses()
.OrderBy(p => p.ProcessName)
.Select(p => new { p.ProcessName })
.Distinct();
VB version doesn't work (New keyword used so data binding will work
correctly):
Dim uniqueProcs = Process.GetProcesses() _
.OrderBy(Function(p) p.ProcessName) _
.Select(Function(p) New With {p.ProcessName}) _
.Distinct()
When I say that the VB version doesn't work, I mean that it returns a
list, but the duplicates are not removed.
Thanks,
Chris
with unique names and it returned the results I
expected. However, curiously, the VB version did not seem to work.
Can anyone correct my VB version so that it returns the same results
as the C# version?
C# version works (new keyword used so data binding will work
correctly):
var uniqueProcs = Process.GetProcesses()
.OrderBy(p => p.ProcessName)
.Select(p => new { p.ProcessName })
.Distinct();
VB version doesn't work (New keyword used so data binding will work
correctly):
Dim uniqueProcs = Process.GetProcesses() _
.OrderBy(Function(p) p.ProcessName) _
.Select(Function(p) New With {p.ProcessName}) _
.Distinct()
When I say that the VB version doesn't work, I mean that it returns a
list, but the duplicates are not removed.
Thanks,
Chris