Сţµç×ÓÊé > ÆäËûµç×ÓÊé > VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ) >

µÚ143ÕÂ

VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ)-µÚ143ÕÂ

С˵£º VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ) ×ÖÊý£º ÿҳ3500×Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡




used¡£¡¡The¡¡From¡¡part¡¡is¡¡the¡¡_tickets¡¡variable¡¡itself¡£¡¡The¡¡Where¡¡part¡¡is¡¡the¡¡method¡¡Where£¨£©£»¡¡and¡¡the¡¡¡¡

Select¡¡part¡¡is¡¡a¡¡default¡¡selection¡¡of¡¡the¡¡currently¡¡selected¡¡node¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡To¡¡specify¡¡an¡¡action¡¡with¡¡Where£¨£©£»¡¡you¡¡use¡¡a¡¡lambda¡¡expression£»¡¡which¡¡has¡¡two¡¡parame

ters£º¡¡the¡¡object¡¡and¡¡the¡¡index¡¡of¡¡the¡¡object¡£¡¡The¡¡lambda¡¡expression¡¡expects¡¡that¡¡you¡¡return¡¡a¡¡¡¡

Boolean¡¡value¡¡indicating¡¡whether¡¡the¡¡ticket¡¡item¡¡should¡¡be¡¡added¡¡to¡¡a¡¡returned¡¡list¡£¡¡

¡¡¡¡¡¡¡¡¡¡LINQ¡¡is¡¡a¡¡syntax¡¡that¡¡wraps¡¡SQL¡­like¡¡text¡£¡¡LINQ¡¡is¡¡much¡¡easier¡¡to¡¡understand¡¡and¡¡program¡¡¡¡

than¡¡using¡¡the¡¡method¡­call¡¡syntax¡¡of¡¡the¡¡previous¡¡example¡£¡¡Using¡¡the¡¡methods¡¡gives¡¡you¡¡more¡¡¡¡

flexibility£»¡¡but¡¡they¡¡also¡¡are¡¡more¡¡plicated¡¡to¡¡write¡£¡¡

¡¡¡¡¡¡¡¡¡¡For¡¡example£»¡¡if¡¡you¡¡wanted¡¡to¡¡find¡¡the¡¡frequency¡¡of¡¡two¡¡numbers¡¡in¡¡a¡¡list£»¡¡you¡¡could¡¡use¡¡¡¡

this¡¡code£º¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡428¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

406¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡1¡¡5¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡I¡¡N¡¡G¡¡¡¡¡¡A¡¡B¡¡OU¡¡T¡¡¡¡¡¡L¡¡I¡¡N¡¡Q¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Function¡¡FrequencyOfTwoNumbersList£¨ByVal¡¡number1ToSearch¡¡As¡¡Integer¡¡£»¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ByVal¡¡number2ToSearch¡¡As¡¡Integer£©¡¡As¡¡Integer¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡query¡¡=¡¡_tickets¡£Where£¨¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Function£¨ticket£»¡¡index£©¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨0£©¡¡=¡¡number1ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨1£©¡¡=¡¡number1ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨2£©¡¡=¡¡number1ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨3£©¡¡=¡¡number1ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨4£©¡¡=¡¡number1ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨5£©¡¡=¡¡number1ToSearch£©¡£Where£¨¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Function£¨ticket£»¡¡index£©¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨0£©¡¡=¡¡number2ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨1£©¡¡=¡¡number2ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨2£©¡¡=¡¡number2ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨3£©¡¡=¡¡number2ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨4£©¡¡=¡¡number2ToSearch¡¡_¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Or¡¡ticket¡£Numbers£¨5£©¡¡=¡¡number2ToSearch£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡query¡£Count£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Function¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡In¡¡the¡¡code£»¡¡the¡¡bolded¡¡line¡¡demonstrates¡¡how¡¡the¡¡output¡¡of¡¡one¡¡method¡¡can¡¡serve¡¡as¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡input¡¡for¡¡another¡¡method¡£¡¡This¡¡chaining¡¡of¡¡methods¡¡works¡¡because¡¡the¡¡list¡¡method¡¡returns¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡other¡¡lists¡£¡¡Thus£»¡¡you¡¡could¡¡add¡¡multiple¡¡criteria¡¡by¡¡concatenating¡¡multiple¡¡Where£¨£©¡¡method¡¡calls¡£¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡methods¡¡are¡¡used¡¡to¡¡filter¡¡or¡¡manipulate¡¡the¡¡set¡¡where¡¡the¡¡details¡¡of¡¡the¡¡method¡¡are¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡provided¡¡by¡¡a¡¡lambda¡¡expression¡£¡¡Table¡¡15¡­1¡¡briefly¡¡describes¡¡some¡¡of¡¡the¡¡useful¡¡methods¡¡that¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡you¡¡can¡¡use¡¡to¡¡filter¡¡and¡¡manipulate¡¡a¡¡list¡£¡¡The¡¡best¡¡way¡¡to¡¡learn¡¡about¡¡all¡¡of¡¡the¡¡methods¡¡is¡¡to¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡use¡¡Visual¡¡Basic¡¡Express£»¡¡declare¡¡a¡¡list£»¡¡and¡¡use¡¡IntelliSense¡¡to¡¡discover¡¡the¡¡different¡¡methods¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡available¡£¡¡Also£»¡¡see¡¡http£º//msdn2¡£microsoft¡£/en¡­us/vbasic/bb688088¡£aspx¡¡for¡¡many¡¡exam

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ples¡¡that¡¡demonstrate¡¡the¡¡various¡¡list¡­manipulation¡¡methods¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Table¡¡15¡­1¡£¡¡Some¡¡Methods¡¡for¡¡Filtering¡¡and¡¡Manipulating¡¡Lists¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Method¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Description¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Aggregate£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Returns¡¡a¡¡fact¡¡about¡¡the¡¡list¡£¡¡A¡¡fact¡¡could¡¡be¡¡how¡¡many¡¡even¡¡numbers¡¡there¡¡are¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡or¡¡the¡¡frequency¡¡of¡¡a¡¡particular¡¡number¡£¡¡All¡¡of¡¡the¡¡elements¡¡in¡¡the¡¡list¡¡are¡¡iterated¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡and¡¡returned¡¡as¡¡a¡¡single¡¡fact£»¡¡not¡¡as¡¡a¡¡list¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡All£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Iterates¡¡all¡¡elements¡¡of¡¡the¡¡list¡¡and¡¡tests¡¡according¡¡to¡¡a¡¡lambda¡¡expression£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡where¡¡a¡¡True¡¡or¡¡False¡¡is¡¡returned¡£¡¡For¡¡example£»¡¡the¡¡test¡¡could¡¡be¡¡to¡¡find¡¡out¡¡if¡¡all¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡objects¡¡have¡¡a¡¡value¡¡greater¡¡than¡¡10¡£¡¡The¡¡test¡¡needs¡¡to¡¡return¡¡only¡¡a¡¡True¡¡or¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡False¡¡value¡¡for¡¡the¡¡individual¡¡object£»¡¡where¡¡the¡¡All£¨£©¡¡method¡¡will¡¡correlate¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡results¡¡and¡¡return¡¡a¡¡True¡¡or¡¡¡¡False¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Any£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Like¡¡All£¨£©£»¡¡except¡¡that¡¡the¡¡question¡¡is¡¡changed¡¡to¡¡test¡¡if¡¡any¡¡of¡¡the¡¡objects¡¡meet¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡criteria£»¡¡such¡¡as¡¡having¡¡a¡¡value¡¡greater¡¡than¡¡10¡£¡¡If¡¡so£»¡¡then¡¡a¡¡True¡¡value¡¡is¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡returned£»¡¡otherwise£»¡¡a¡¡False¡¡value¡¡is¡¡returned¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Average£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Calculates¡¡the¡¡average¡¡of¡¡a¡¡sequence¡¡of¡¡values¡£¡¡The¡¡average¡¡value¡¡returned¡¡is¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a¡¡numeric¡¡Decimal¡¡value¡£¡¡This¡¡method¡¡is¡¡a¡¡bit¡¡odd£»¡¡because¡¡to¡¡calculate¡¡an¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡average£»¡¡you¡¡need¡¡numbers£»¡¡even¡¡though¡¡the¡¡lambda¡¡expression¡¡could¡¡calcu

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡late¡¡the¡¡average¡¡of¡¡objects¡£¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡429¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡1¡¡5¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡I¡¡N¡¡G¡¡¡¡¡¡A¡¡B¡¡OU¡¡T¡¡¡¡¡¡L¡¡I¡¡N¡¡Q¡¡407¡¡



Table¡¡15¡­1¡£¡¡Some¡¡Methods¡¡for¡¡Filtering¡¡and¡¡Manipulating¡¡Lists¡¡£¨Continued£©¡¡



Method¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Description¡¡



Cast£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Returns¡¡a¡¡list¡¡where¡¡each¡¡item¡¡is¡¡converted¡¡from¡¡the¡¡list¡¡type¡¡to¡¡another¡¡type¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡This¡¡is¡¡a¡¡good¡¡method¡¡to¡¡use¡¡when¡¡you¡¡need¡¡to¡¡perform¡¡bulk¡¡conversions¡¡of¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡instance¡¡types¡¡in¡¡a¡¡list¡£¡¡



Concat£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Concatenates¡¡two¡¡lists¡£¡¡¡¡



Contains£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Verifies¡¡whether¡¡an¡¡item¡¡is¡¡present¡¡in¡¡the¡¡list¡£¡¡The¡¡method¡¡uses¡¡a¡¡lambda¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡expression¡¡to¡¡determine¡¡whether¡¡the¡¡specified¡¡item¡¡is¡¡in¡¡the¡¡list£»¡¡and¡¡returns¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡True¡¡or¡¡¡¡False¡¡accordingly¡£¡¡



ConvertAll£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Returns¡¡a¡¡list¡¡where¡¡each¡¡item¡¡is¡¡converted¡¡from¡¡the¡¡list¡¡type¡¡to¡¡another¡¡type¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡This¡¡is¡¡a¡¡good¡¡method¡¡to¡¡use¡¡when¡¡you¡¡need¡¡to¡¡perform¡¡bulk¡¡conversions¡¡of¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡instance¡¡types¡¡in¡¡a¡¡list¡£¡¡



Distinct£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Removes¡¡all¡¡duplicates¡¡from¡¡a¡¡list¡£¡¡By¡¡default£»¡¡the¡¡implementation¡¡of¡¡Distinct£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡checks¡¡for¡¡equality¡¡by¡¡calling¡¡GetHashCode£¨£©¡¡first£»¡¡and¡¡then¡¡calling¡¡¡¡Equals£¨£©¡¡if¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡necessary¡£¡¡A¡¡variation¡¡of¡¡the¡¡Distinct£¨£©¡¡method¡¡is¡¡to¡¡supply¡¡an¡¡¡¡IEqualityparer¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡interface¡¡instance¡¡that¡¡can¡¡be¡¡used¡¡to¡¡determine¡¡whether¡¡two¡¡types¡¡are¡¡equal¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡However£»¡¡a¡¡better¡¡approach¡¡would¡¡be¡¡to¡¡implement¡¡GetHashCode£¨£©¡¡and¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Equals£¨£©¡£¡¡



Except£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Takes¡¡the¡¡current¡¡list¡¡and¡¡a¡¡passed¡­in¡¡list¡¡and¡¡performs¡¡a¡¡difference¡¡between¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡two¡¡sets£»¡¡which¡¡is¡¡returned¡¡to¡¡the¡¡caller¡¡as¡¡a¡¡new¡¡dataset¡£¡¡The¡¡equality¡¡tests¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡are¡¡identical¡¡to¡¡Distinct£¨£©¡£¡¡



Find£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Finds¡¡an¡¡element¡¡of¡¡a¡¡particular¡¡list¡£¡¡Note¡¡that¡¡the¡¡lambda¡¡expression¡¡you¡¡use¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡when¡¡it¡¡has¡¡found¡¡an¡¡element¡¡will¡¡cause¡¡the¡¡¡¡Find£¨£©¡¡method¡¡to¡¡stop¡¡processing¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡list¡¡and¡¡return¡¡what¡¡you¡¡marked¡¡as¡¡found¡£¡¡¡¡



FindAll£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Like¡¡Find£¨£©£»¡¡except¡¡you¡¡can¡¡find¡¡multiple¡¡elements¡¡in¡¡a¡¡list¡£¡¡This¡¡is¡¡like¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Where£¨£©¡¡method¡£¡¡



FindLast£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Like¡¡Find£¨£©£»¡¡except¡¡the¡¡search¡¡starts¡¡at¡¡the¡¡end¡¡of¡¡the¡¡list¡£¡¡



ForEach£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡An¡¡iterator¡¡that¡¡uses¡¡a¡¡lambda¡¡expression¡¡to¡¡process¡¡each¡¡element¡£¡¡The¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ForEach£¨£©¡¡method¡¡is¡¡a¡¡simplification¡¡of¡¡the¡¡code¡¡illustrated¡¡in¡¡Chapter¡¡9¡£¡¡



GroupBy£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Takes¡¡a¡¡list¡¡and¡¡splits¡¡it¡¡into¡¡specific¡¡groupings¡¡as¡¡per¡¡the¡¡provided¡¡lambda¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡expression¡£¡¡For¡¡example£»¡¡you¡¡could¡¡use¡¡it¡¡to¡¡split¡¡the¡¡earnings¡¡of¡¡individuals¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡into¡¡brackets¡£¡¡



Intersect£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Takes¡¡the¡¡current¡¡list¡¡and¡¡a¡¡provided¡¡list¡¡and¡¡determines¡¡the¡¡elements¡¡that¡¡are¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mon¡¡to¡¡both¡¡lists¡£¡¡Uses¡¡the¡¡same¡¡equality¡¡tests¡¡as¡¡Distinct£¨£©¡£¡¡



Max£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Finds¡¡the¡¡maximum¡¡value¡¡of¡¡a¡¡list¡£¡¡



Min£¨£©¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Finds¡¡the¡¡minimum¡¡va

·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨2£© ²È£¨2£©

Äã¿ÉÄÜϲ»¶µÄ