CSharp C# Tuple Linq search get IEnumerable from List
meta: predicate
Output:
joe_Now.Item1 = Joe
joe_Now.Item2 = Joe_First
joe_Now.Item1 = Joe
joe_Now.Item2 = Joe_Second
press enter to finish
|
Program.cs:
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleStuff
{
class Program
{
static void Main(string[] args)
{
List<Tuple<string, string>> tupleCollectionOptionalClasses = new List<Tuple<string, string>>();
tupleCollectionOptionalClasses.Add(new Tuple<string, string>("Hank","Hank_First"));
tupleCollectionOptionalClasses.Add(new Tuple<string, string>("Joe", "Joe_First"));
tupleCollectionOptionalClasses.Add(new Tuple<string, string>("Mary", "Mary_First"));
tupleCollectionOptionalClasses.Add(new Tuple<string, string>("Joe", "Joe_Second"));
tupleCollectionOptionalClasses.Add(new Tuple<string, string>("Hank", "Hank_Second"));
IEnumerable<Tuple<string, string>> tuple_JustJoe = tupleCollectionOptionalClasses.Where(
delegate(Tuple<string, string> mapNowFinder)
{
return mapNowFinder.Item1 == "Joe"; // case sensitive
}
);
foreach (Tuple<string, string> joe_Now in tuple_JustJoe)
{
Console.WriteLine("joe_Now.Item1 = {0}
joe_Now.Item2 = {1}", joe_Now.Item1, joe_Now.Item2);
}
Console.WriteLine();
Console.WriteLine("press enter to
finish");
Console.ReadLine();
}
}
}
|
it’s ok to show some appreciation and say ‘great post’
ReplyDeleteAsp .NET developer
nic post
ReplyDeletehttp://mkniit.blogspot.in