You are implementing an ASP.NET application. You add the following code segment.
Public Function GetNonSecretUsers() As List(Of Person)
Dim secretUsers() As String =
{“@secretUser”, “@admin”, “@root”}
Dim allpeople As List(Of Person) = GetAllPeople()
…
End Function
You need to add code to return a list of all Person objects except those with a UserId that is
contained in the secretUsers list. The resulting list must not contain duplicates. Which code segment
should you use?
A.
Dim secretPeople = (From p In allpeople
From u In secretUsers
Where p.UserId = u
Select p).Distinct()
Return allpeople.Except(secretPeople)
B.
Return From p In allpeople
From u In secretUsers
Where p.UserId <> u
Select p
C.
Return (From p In allpeople
From u In secretUsers
Where p.UserId <> u
Select p).Distinct()
D.
Dim people As List(Of Person) = New List(Of Person)(
From p In allpeople
From u In secretUsers
Where p.UserId <> u
Select p) Return people.Distinct()