PagodNaUtak
asked on
Select an item on the list that is not on the other list.
Hi, I have two list defaultSortOptions and savedSortOptions:
Dim defaultSortOptions as new List(Of SortOption)
Dim savedSortOptions as new List(Of SortOption)
How do I :
1.) Select all sortoption in the defaultSortOptions list that is not in the savedSortoption
2.) Select those sortoption in the defaultSortoption list that is differ in the sortoption text but similar sortoption ID in the savedSortOption lists.
Need to use LINQ in this...
If you need further clarificatio please fill free to ask me.
Regards,
Joseph
Dim defaultSortOptions as new List(Of SortOption)
Dim savedSortOptions as new List(Of SortOption)
How do I :
1.) Select all sortoption in the defaultSortOptions list that is not in the savedSortoption
2.) Select those sortoption in the defaultSortoption list that is differ in the sortoption text but similar sortoption ID in the savedSortOption lists.
Need to use LINQ in this...
If you need further clarificatio please fill free to ask me.
Regards,
Joseph
Public Class SortOption
Private _id As Integer
Private _text As String
Public Property ID() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
Public Property Text() As String
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
End Set
End Property
End Class
hi,
try this way tooo
try this way tooo
string[] words = { "Asp", ".net", "php", "vb", "c", "c#", "f#", "c++" };
string[] wos = { "Asp", ".net", "php", "vb", "c", "c#" };
var tmp = words.Except(wos);
For the "matchingId" query, if you need the text to strictly be different, then you can modify the query to this:
Dim matchingId = From item1 In defaultSortOptions _
From item2 In savedSortOptions _
Where item1.ID = item2.ID AndAlso item1.Text <> item2.Text _
Select item1
ASKER
Hi kaufmed,
it does not work...
Please see below code... for more details...
The output is:
-------------------------- -
1 Newest to oldest
2 Oldest to newest
3 Most Popular
4 Featured Sort
5 New Order
it does not work...
Please see below code... for more details...
The output is:
--------------------------
1 Newest to oldest
2 Oldest to newest
3 Most Popular
4 Featured Sort
5 New Order
Dim defaultSortOptions As New List(Of SortOption)
Dim savedSortOptions As New List(Of SortOption)
Dim newOrder As New List(Of SortOption)
defaultSortOptions.Add(New SortOption(1, "Newest to oldest"))
defaultSortOptions.Add(New SortOption(2, "Oldest to newest"))
defaultSortOptions.Add(New SortOption(3, "Most Popular"))
defaultSortOptions.Add(New SortOption(4, "Featured Sort"))
defaultSortOptions.Add(New SortOption(5, "New Order"))
savedSortOptions.Add(New SortOption(1, "Newest to oldest"))
savedSortOptions.Add(New SortOption(2, "Oldest to newest"))
savedSortOptions.Add(New SortOption(3, "Most Popular"))
savedSortOptions.Add(New SortOption(4, "By Topic"))
Dim notIn = From item In defaultSortOptions _
Where Not savedSortOptions.Contains(item) _
Select item
Response.Write("---------------------------")
Response.Write("<br />")
For Each sort In notIn
Response.Write(sort.ID & " " & sort.Text)
Response.Write("<br />")
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window