TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Shinde
NA
7
0
Search item into list by passing another list with where ?
Jan 17 2014 7:24 AM
Hi,
I am trying to search the item into list by passing another list with where condition using linq.
here is my code:
public class ClassItemA
{
public string item { get; set; }
public short count { get; set; }
}
public class ClassItemB
{
public string item { get; set; }
}
class Program
{
static void Main(string[] args)
{
List<ClassItemA> b = new List<ClassItemA>();
string[] s = { "B00B0YJQPK", "B0046HF4AY" };
string[] s1 = { "B00BGL8YWS", "B0006G4MH0" };
foreach (string sb in s)
{
ClassItemA cb = new ClassItemA();
cb.item = sb.ToString();
cb.count = 10;
b.Add(cb);
}
foreach (string sb in s1)
{
ClassItemA cb = new ClassItemA();
cb.item = sb.ToString();
cb.count = 0;
b.Add(cb);
}
List<ClassItemB> c = new List<ClassItemB>();
string[] s2 = { "B00B0YJQPK", "B0046HF4AY", "B00BGL8YWS", "B0006G4MH0" };
foreach (string sb in s2)
{
ClassItemB cc = new ClassItemB();
cc.item = sb.ToString();
c.Add(cc);
}
Console.ReadLine();
}
--
Now I have to write a linq to get the items form classItemB object where items from ClassItemA which has count > 0.
Please suggest.
Reply
Answers (
3
)
Grouping Strings and Adding into a List<t>
Fnding children records in a self referencing collection