°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡accounts¡£Add£¨new¡¡Account£¨¡¨Christian¡¨£»¡¡1500£©£©£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡accounts¡£Add£¨new¡¡Account£¨¡¨Sharon¡¨£»¡¡2200£©£©£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡accounts¡£Add£¨new¡¡Account£¨¡¨Katie¡¨£»¡¡1800£©£©£»
ÀÛ¼ÓËùÓÐAccount¶ÔÏóµÄ´«Í³·½Ê½ÊÇÓÃforeachÓï¾äµü´úËùÓеÄAccount¶ÔÏó£¬ÈçÏÂËùʾ¡£foreachÓï¾äʹÓÃIEnumerable½Ó¿Úµü´ú¼¯ºÏµÄÔªËØ£¬ËùÒÔAccumulateSimple£¨£©·½·¨µÄ²ÎÊýÊÇIEnumerableÀàÐÍ¡£ÕâÑù£¬AccumulateSimple£¨£©·½·¨¾Í¿ÉÒÔÓÃÓÚËùÓÐʵÏÖIEnumerable½Ó¿ÚµÄ¼¯ºÏÀà¡£ÔÚÕâ¸ö·½·¨µÄʵÏÖ´úÂëÖУ¬Ö±½Ó·ÃÎÊAccount¶ÔÏóµÄBalanceÊôÐÔ£º
¡¡¡¡¡¡public¡¡static¡¡class¡¡Algorithm
¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡public¡¡static¡¡decimal¡¡AccumulateSimple£¨IEnumerable¡¡e£©
¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡decimal¡¡sum¡¡=¡¡0£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡foreach¡¡£¨Account¡¡a¡¡in¡¡e£©
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡sum¡¡£«=¡¡a¡£Balance£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£ý
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡return¡¡sum£»
¡¡¡¡¡¡¡¡¡¡¡¡£ý
¡¡¡¡¡¡£ý
Accumulate£¨£©·½·¨µÄµ÷Ó÷½Ê½ÈçÏ£º
¡¡¡¡¡¡¡¡¡¡¡¡decimal¡¡amount¡¡=¡¡Algorithm¡£AccumulateSimple£¨accounts£©£»
µÚÒ»¸öʵÏÖ´úÂëµÄÎÊÌâÊÇ£¬ËüÖ»ÄÜÓÃÓÚAccount¶ÔÏó¡£Ê¹Ó÷ºÐÍ·½·¨¾Í¿ÉÒÔ±ÜÃâÕâ¸öÎÊÌâ¡£
Accumulate£¨£©·½·¨µÄµÚ¶þ¸ö°æ±¾½ÓÊÜʵÏÖÁËIAccount½Ó¿ÚµÄÈÎÒâÀàÐÍ¡£ÈçÇ°ÃæµÄ·ºÐÍÀàËùÊö£¬·ºÐÍÀàÐÍ¿ÉÒÔÓÃwhere×Ó¾äÀ´ÏÞÖÆ¡£Õâ¸ö×Ó¾äÒ²¿ÉÒÔÓÃÓÚ·ºÐÍ·½·¨¡£Accumulate£¨£©·½·¨µÄ²ÎÊý¸ÄΪIEnumerable¡£IEnumerableÊÇIEnumerable½Ó¿ÚµÄ·ºÐÍ°æ±¾£¬ÓÉ·ºÐͼ¯ºÏÀàʵÏÖ¡£
¡¡¡¡¡¡¡¡¡¡¡¡public¡¡static¡¡decimal¡¡Accumulate£¨IEnumerable¡¡coll£©
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡where¡¡TAccount¡¡£º¡¡IAccount
¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡decimal¡¡sum¡¡=¡¡0£»
¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡foreach¡¡£¨TAccount¡¡a¡¡in¡¡coll£©
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡sum¡¡£«=¡¡a¡£Balance£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£ý
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡return¡¡sum£»
¡¡¡¡¡¡¡¡¡¡¡¡£ý
AccountÀàÏÖÔÚÖع¹ÎªÖ´ÐнӿÚIAccount£º
public¡¡class¡¡Account¡¡£º¡¡IAccount
£û
//¡£¡£¡£
IAccount½Ó¿Ú¶¨ÒåÁËÖ»¶ÁÊôÐÔBalanceºÍName£º
public¡¡interface¡¡IAccount
£û
decimal¡¡Balance¡¡£û¡¡get£»¡¡£ý
string¡¡Name¡¡£û¡¡get£»¡¡£ý
£ý
½«AccountÀàÐͶ¨ÒåΪ·ºÐÍÀàÐͲÎÊý£¬¾Í¿ÉÒÔµ÷ÓÃеÄAccumulate£¨£©·½·¨£º
¡¡¡¡¡¡¡¡¡¡¡¡decimal¡¡amount¡¡=¡¡Algorithm¡£Accumulate£¨accounts£©£»
ÒòΪ±àÒëÆ÷»á´Ó·½·¨µÄ²ÎÊýÀàÐÍÖÐ×Ô¶¯Íƶϳö·ºÐÍÀàÐͲÎÊý£¬ËùÒÔÒÔÈçÏ·½Ê½µ÷ÓÃAccumulate£¨£©·½·¨ÊÇÓÐЧµÄ£º
¡¡¡¡¡¡¡¡¡¡¡¡decimal¡¡amount¡¡=¡¡Algorithm¡£Accumulate£¨accounts£©£»
·ºÐÍÀàÐÍʵÏÖIAccount½Ó¿ÚµÄÒªÇó¹ýÓÚÑÏÀ÷¡£Õâ¸öÒªÇó¿ÉÒÔʹÓ÷ºÐÍίÍÐÀ´¸Ä±ä¡£ÔÚÏÂÒ»½ÚÖУ¬Accumulate£¨£©·½·¨½«¸ÄΪ¶ÀÁ¢ÓÚÈκνӿڡ£
9¡£6¡¡¡¡·ºÐÍίÍÐ
ÈçµÚ7ÕÂËùÊö£¬Î¯ÍÐÊÇÀàÐÍ°²È«µÄ·½·¨ÒýÓá£Í¨¹ý·ºÐÍίÍУ¬Î¯ÍеIJÎÊý¿ÉÒÔÔÚÒÔºó¶¨Òå¡£
¡¡Framework¶¨ÒåÁËÒ»¸ö·ºÐÍίÍÐEventHandler£¬ËüµÄµÚ¶þ¸ö²ÎÊýÊÇTEventArgsÀàÐÍ£¬ËùÒÔ²»ÔÙÐèҪΪÿ¸öвÎÊýÀàÐͶ¨ÒåÐÂίÍÐÁË¡£
public¡¡sealed¡¡delegate¡¡void¡¡EventHandler£¨object¡¡sender£»¡¡TEventArgs¡¡e£©
where¡¡TEventArgs¡¡£º¡¡EventArgs
9¡£6¡£1¡¡¡¡Ö´ÐÐίÍе÷Óõķ½·¨
°ÑAccumulate£¨£©·½·¨¸ÄΪÓÐÁ½¸ö·ºÐÍÀàÐÍ¡£TInputÊÇÒªÀۼӵĶÔÏóÀàÐÍ£¬TSummaryÊÇ·µ»ØÀàÐÍ¡£AccumulateµÄµÚÒ»¸ö²ÎÊýÊÇIEnumerable½Ó¿Ú£¬ÕâÓëÒÔÇ°Ïàͬ¡£µÚ¶þ¸ö²ÎÊýÐèÒªActionίÍÐÒýÓÃÒ»¸ö·½·¨£¬À´ÀÛ¼ÓËùÓеĽáÓà¡£
ÔÚʵÏÖ´úÂëÖУ¬ÏÖÔÚ¸øÿ¸öÔªËص÷ÓÃActionίÍÐÒýÓõķ½·¨£¬ÔÙ·µ»Ø¼ÆËãµÄ×ܺͣº
public¡¡delegate¡¡TSummary¡¡Action£¨TInput¡¡t£»¡¡TSummary¡¡u£©£»
public¡¡static¡¡TSummary¡¡Accumulate£¨IEnumerable¡¡coll£»
¡¡¡¡¡¡¡¡¡¡¡¡Action¡¡action£©
£û
¡¡¡¡¡¡TSummary¡¡sum¡¡=¡¡default£¨TSummary£©£»
¡¡¡¡¡¡foreach¡¡£¨TInput¡¡input¡¡in¡¡coll£©
¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡sum¡¡=¡¡action£¨input£»¡¡sum£©£»
¡¡¡¡¡¡£ý
¡¡¡¡¡¡return¡¡sum£»
£ý
Accumulate·½·¨¿ÉÒÔͨ¹ýÄäÃû·½·¨µ÷Ó㬸ÃÄäÃû·½·¨Ö¸¶¨£¬ÕËÄ¿µÄ½áÓàÓ¦ÀÛ¼Óµ½µÚ¶þ¸öActionÀàÐ͵IJÎÊýÖУº
¡¡¡¡¡¡¡¡¡¡¡¡decimal¡¡amount¡¡=¡¡Algorithm¡£Accumulate£¨
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡accounts£»
delegate£¨Account¡¡a£»¡¡decimal¡¡d£©
£û¡¡return¡¡a¡£Balance¡¡£«¡¡d£»¡¡£ý£©£»
³ýÁËʹÓÃÄäÃû·½·¨Ö®Í⣬»¹¿ÉÒÔʹÓÃl±í´ïʽ°ÑËü´«Ë͸øµÚ¶þ¸ö²ÎÊý£º
decimal¡¡amount¡¡=¡¡Algorithm¡£Accumulate¡¡¡¶¡¡Account£»¡¡decimal¡¡¡·¡¡£¨
accounts£»¡¡£¨a£»¡¡d£©¡¡=¡¡¡·¡¡a¡£Balance¡¡£«¡¡d£»£©£»
Ìáʾ£º
ÄäÃû·½·¨ºÍl±í´ïʽ²Î¼ûµÚ7Õ¡£
Èç¹ûAccount½áÓàµÄÀÛ¼ÓÐèÒª½øÐжà´Î£¬¾Í¿ÉÒ԰Ѹù¦ÄÜ·ÅÔÚÒ»¸öAccountAdder£¨£©·½·¨ÖУº
¡¡¡¡¡¡¡¡¡¡¡¡static¡¡decimal¡¡AccountAdder£¨Account¡¡a£»¡¡decimal¡¡d£©
¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡return¡¡a¡£Balance¡¡£«¡¡d£»
¡¡¡¡¡¡¡¡¡¡¡¡£ý
ÁªºÏʹÓÃAccountAdder·½·¨ºÍAccumulate·½·¨£º
¡¡¡¡¡¡¡¡¡¡¡¡decimal¡¡amount¡¡=¡¡Algorithm¡£Accumulate£¨
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡accounts£»¡¡AccountAdder£©£»
ActionίÍÐÒýÓõķ½·¨¿ÉÒÔʵÏÖÈκÎÂß¼¡£ÀýÈ磬¿ÉÒÔ½øÐг˷¨²Ù×÷£¬¶ø²»ÊǼӷ¨²Ù×÷¡£
Accumulate£¨£©·½·¨ºÍAccumulateIf£¨£©·½·¨Ò»ÆðʹÓ㬻á¸üÁé»î¡£ÔÚAccumulateIf£¨£©ÖУ¬Ê¹ÓÃÁËÁíÒ»¸öPredicateÀàÐ͵IJÎÊý¡£PredicateίÍÐÒýÓõķ½·¨»á¼ì²éij¸öÕËÄ¿ÊÇ·ñÓ¦ÀÛ¼Ó½øÈ¥¡£ÔÚforeachÓï¾äÖУ¬Ö»ÓÐν´Êmatch·µ»Øtrue£¬²Å»áµ÷ÓÃaction·½·¨£º
¡¡¡¡¡¡¡¡¡¡¡¡public¡¡static¡¡TSummary¡¡AccumulateIf£¨
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡IEnumerable¡¡coll£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Action¡¡action£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Predicate¡¡match£©
¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡TSummary¡¡sum¡¡=¡¡default£¨TSummary£©£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡foreach¡¡£¨TInput¡¡a¡¡in¡¡coll£©
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if¡¡£¨match£¨a£©£©
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£û
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡sum¡¡=¡¡action£¨a£»¡¡sum£©£»
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£ý
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£ý
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡return¡¡sum£»
¡¡¡¡¡¡¡¡¡¡¡¡£ý
µ÷ÓÃAccumulateIf£¨£©·½·¨¿ÉÒÔʵÏÖÀÛ¼ÓºÍÖ´ÐÐν´Ê¡£ÕâÀï°´ÕÕµÚ¶þ¸öl±í´ïʽµÄ¶¨Òåa¡¡=¡¡¡·¡¡a¡£Balance¡¡¡·¡¡2000£¬Ö»ÀÛ¼Ó½áÓà´óÓÚ2000µÄÕËÄ¿£º
decimal¡¡amount¡¡=¡¡Algorithm¡£AccumulateIf¡¡¡¶¡¡Account£»¡¡decimal¡¡¡·¡¡£¨
accounts£»¡¡£¨a£»¡¡d£©¡¡=¡¡¡·¡¡a¡£Balance¡¡£«¡¡d£»¡¡a¡¡=¡¡¡·¡¡a¡£Balance¡¡¡·¡¡2000£©£»
9¡£6¡£2¡¡¡¡¶ÔArrayÀàʹÓ÷ºÐÍίÍÐ
µÚ5ÕÂʹÓÃIparableºÍIparer½Ó¿Ú£¬ÑÝʾÁËArrayÀàµÄ¼¸¸öÅÅÐò¼¼Êõ¡£´Ó¡¡2¡£0¿ªÊ¼£¬ArrayÀàµÄһЩ·½·¨°Ñ·ºÐÍίÍÐÀàÐÍÓÃ×÷²ÎÊý¡£±í9¡2ÁгöÁËÕâЩ·½·¨¡¢·ºÐÍÀàÐͺ͹¦ÄÜ¡£
±í¡¡¡¡9¡2
·½¡¡¡¡¡¡¡¡·¨
·ºÐͲÎÊýÀàÐÍ
˵¡¡¡¡¡¡¡¡Ã÷
Sort£¨£©
int¡¡parison£¨T¡¡x£»¡¡T¡¡y£©
Sort£¨£©·½·¨¶¨ÒåÁ˼¸¸öÖØÔØ°æ±¾¡£ÆäÖÐÒ»¸öÖØÔØ°æ±¾ÐèÒªÒ»¸öparisonÀàÐ͵IJÎÊý¡£Sort£¨£©Ê¹ÓÃίÍÐÒýÓõķ½·¨¶Ô¼¯ºÏÖеÄËùÓÐÔªËØÅÅÐò
ForEach£¨£©
void¡¡Action£¨T¡¡obj£©
ForEach£¨£©·½·¨¶Ô¼¯ºÏÖеÄÿһÏîµ÷ÓÃÓÉActionίÍÐÒýÓõķ½·¨
FindAll£¨£©
Find£¨£©
FindLast£¨£©
FindIndex£¨£©
FindLastIndex£¨£©
bool¡¡Predicate£¨T¡¡match£©
FindXXX£¨£©·½·¨½«PredicateίÍÐ×÷ΪÆä²ÎÊý¡£ÓÉίÍÐÒýÓõķ½·¨»áµ÷Óöà´Î£¬²¢Ò»¸ö½ÓÒ»¸öµØ´«Ëͼ¯ºÏÖеÄÔªËØ¡£Find£¨£©·½·¨ÔÚν´ÊµÚÒ»´Î·µ»ØtrueʱֹͣËÑË÷£¬²¢·µ»ØÕâ¸öÔªËØ¡£FindIndex£¨£©·µ»Ø²éÕÒµ½µÄµÚÒ»¸öÔªËصÄË÷Òý¡£FindLast£¨£©ºÍFindLastIndex£¨£©ÒÔÄæÐò·½Ê½¶Ô¼¯ºÏÖеÄÔªËص÷ÓÃν´Ê£¬Òò´Ë·µ»Ø×îºóÒ»Ïî»ò×îºóÒ»¸öË÷Òý¡£FindAll£¨£©·µ»ØÒ»¸öÐÂÁÐ±í£¬ÆäÖаüº¬Î½´ÊΪtrueµÄËùÓÐÏî
ConvertAll£¨£©
TOutput¡¡Converter£¨TInput¡¡input£©
ConvertAll£¨£©·½·¨¸ø¼¯ºÏÖеÄÿ¸öÔªËص÷ÓÃConverter¡¶¡¡TInput£»¡¡TOutput¡·Î¯ÍУ¬·µ»ØÒ»ÁÐת»»ºÃµÄÔªËØ
TrueForAll£¨£©
bool¡¡Predicate£¨T¡¡match£©
TrueForAll£¨£©·½·¨¸øÿ¸öÔªËص÷ÓÃν´ÊίÍС£Èç¹ûν´Ê¸øÿ¸öÔªËض¼·µ»Øtrue£¬ÔòTrueForAll£¨£©Ò²·µ»Øtrue¡£Èç¹ûν´ÊΪһ¸öÔªËØ·µ»ØÁËfalse£¬TrueForAll£¨£©¾Í·µ»Øfalse
¡¡
ÏÂÃæ¿´¿´ÈçºÎʹÓÃÕâЩ·½·¨¡£
Sort£¨£©·½·¨°ÑÕâ¸öίÍÐ×÷Ϊ²ÎÊý£º
public¡¡delegate¡¡int¡¡parison£¨T¡¡x£»¡¡T¡¡y£©£»
ÕâÑù£¬¾Í¿ÉÒÔʹÓÃl±í´ïʽ´«ËÍÁ½¸öPerson¶ÔÏ󣬸øÊý×éÅÅÐò¡£¶ÔÓÚPerson¶ÔÏóÊý×飬²ÎÊýTÊÇPersonÀàÐÍ£º
Person£§£§¡¡persons¡¡=¡¡£û
new¡¡Person£¨¡¨Emerson¡¨£»¡¡¡¨Fittipaldi¡¨£©£»
new¡¡Person£¨¡¨Niki¡¨£»¡¡¡¨Lauda¡¨£©£»
new¡¡Person£¨¡¨Ayrton¡¨£»¡¡¡¨Senna¡¨£©£»
new¡¡Person£¨¡¨Michael¡¨£»¡¡¡¨Schumacher¡¨£©
£ý£»
Array¡£Sort£¨persons£»¡¡£¨p1£»¡¡p2£©=¡·¡¡p1¡£FirstnamepareTo£¨p2¡£Firstname£©£©£»
Array¡£ForEach£¨£©·½·¨½«ActionίÍÐ×÷Ϊ²ÎÊý£¬¸øÊý×éµÄÿ¸öÔªËØÖ´ÐвÙ×÷£º
public¡¡delegate¡¡void¡¡Action£¨T¡¡obj£©£»
ÓÚÊÇ£¬¾Í¿ÉÒÔ´«ËÍConsole¡£WriteLine·½·¨µÄµØÖ·£¬½«Ã¿¸öÈËдÈë¿ØÖÆ̨¡£WriteLine£¨£©·½·¨µÄÒ»¸öÖØÔØ°æ±¾½«ObjectÀà×÷Ϊ²ÎÊýÀàÐÍ¡£ÓÉÓÚPersonÅÉÉúÓÚObject£¬ËùÒÔËüÊʺÏÓÚPersonÊý×飺
Array¡£ForEach£¨persons£»¡¡Console¡£WriteLine£©£»
ForEach£¨£©Óï¾äµÄ½á¹û½«persons±äÁ¿ÒýÓõļ¯ºÏÖеÄÿ¸öÈ˶¼Ð´Èë¿ØÖÆ̨£º
Emerson¡¡Fittipaldi
Niki¡¡Lauda
Ayrton¡¡Senna
Michael¡¡Schumacher
Èç¹ûÐèÒª¸ü¶àµÄ¿ØÖÆ£¬Ôò¿ÉÒÔ´«ËÍÒ»¸öl±í´ïʽ£¬Æä²ÎÊýӦƥÅäίÍж¨ÒåµÄ²ÎÊý£º
Array¡£ForEach£¨persons£»¡¡p=¡·¡¡Console¡£WriteLine£¨¡¨£û0£ý¡¨£»¡¡p¡£Lastname£©£©£»
ÏÂÃæÊÇдÈë¿ØÖÆ̨µÄÐÕÊÏ£º
Fittipaldi
Lauda
Senna
Schumacher
Array¡£FindAll£¨£©·½·¨ÐèÒªPredicateίÍУº
public¡¡delegate¡¡bool¡¡Predicate£¨T¡¡match£©£»
Array¡£FindAll£¨£©·½·¨ÎªÊý×éÖеÄÿ¸öÔªËص÷ÓÃν´Ê£¬²¢·µ»ØÒ»¸öν´ÊÊÇtrueµÄÊý×é¡£ÔÚÕâ¸öÀý×ÓÖУ¬¶ÔÓÚLastnameÒÔ×Ö·û´®¡¨S¡¨¿ªÍ·µÄËùÓÐPerson¶ÔÏ󣬶¼·µ»Øtrue¡£
Person£§£§¡¡sPersons¡¡=¡¡Array¡£FindAll£¨persons£»¡¡p=¡·¡¡p¡£Lastname¡£StartsWith£¨¡¨S¡¨£©£»
µü´ú·µ»ØµÄ¼¯ºÏsPersons£¬²¢Ð´Èë¿ØÖÆ̨£¬½á¹ûÈçÏ£º
Ayrton¡¡Senna
Michael¡¡Schumacher
ArraynvertAll£¨£©·½·¨Ê¹Ó÷ºÐÍίÍÐConverterºÍÁ½¸ö·ºÐÍÀàÐÍ¡£µÚÒ»¸ö·ºÐÍÀàÐÍTInputÊÇÊäÈë²ÎÊý£¬µÚ¶þ¸ö·ºÐÍÀàÐÍTOutputÊÇ·µ»ØÀàÐÍ¡£
public¡¡delegate¡¡TOutput¡¡Converter£¨TInput¡¡input£©£»
Èç¹ûÒ»ÖÖÀàÐ͵ÄÊý×éӦת»»ÎªÁíÒ»ÖÖÀàÐ͵ÄÊý×飬¾Í¿ÉÒÔʹÓÃConvertAll£¨£©·½·¨¡£ÏÂÃæÊÇÒ»¸öÓëPersonÀàÎ޹صÄRacerÀà¡£PersonÀàÓÐFirstnameºÍLastnameÊôÐÔ£¬¶øRacerÀàΪÈüÊÖµÄÐÕÃû¶¨ÒåÁËÒ»¸öÊôÐÔName£º
public¡¡class¡¡Racer
£û
public¡¡Racer£¨string¡¡name£©
£û
this¡£name¡¡=¡¡name£»
£ý¡¡
public¡¡string¡¡Name¡¡£ûget£»¡¡set£ý
public¡¡string¡¡Team¡¡£ûget£»¡¡set£ý
£ý
ʹÓÃArraynvertAll£¨£©£¬ºÜÈÝÒ×½«personsÊý×éת»»ÎªRacerÊý×é¡£¸øÿ¸öPersonÔªËص÷ÓÃίÍС£ÔÚÿ¸öPersonÔªËصÄÄäÃû·½·¨µÄÖ´ÐдúÂëÖУ¬´´½¨ÁËÒ»¸öеÄRacer¶ÔÏ󣬽«firstnameºÍlastnameÁ¬½ÓÆðÀ´´«Ë͸ø´øÒ»¸ö×Ö·û´®²ÎÊýµÄ¹¹Ô캯Êý¡£½á¹ûÊÇÒ»¸öRacer¶ÔÏóÊý×飺
Racer£§£§¡¡racers¡¡=
ArraynvertAll£¨
persons£»¡¡p¡¡=¡¡¡·
new¡¡Racer£¨String¡£Format£¨¡¨£û0£ý¡¡£û1£ý¡¨£»¡¡p¡£FirstName£»¡¡p¡£LastName£©£©£»
9¡£7¡¡¡¡FrameworkµÄÆäËû·ºÐÍÀàÐÍ
³ýÁËSystemllections¡£GenericÃüÃû¿Õ¼äÖ®Í⣬¡¡Framework»¹ÓÐÆäËû·ºÐÍÀàÐÍ¡£ÕâÀïÌÖÂ۵ĽṹºÍίÍж¼Î»ÓÚSystemÃüÃû¿Õ¼äÖУ¬ÓÃÓÚ²»Í¬µÄÄ¿µÄ¡£
±¾½ÚÌÖÂÛÈçÏÂÄÚÈÝ£º
¡ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡½á¹¹Nullable
¡ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡Î¯ÍÐEventHandler
¡ñ¡¡¡¡¡¡¡¡¡¡¡¡¡¡½á¹¹ArraySegment
9¡£7¡£1¡¡¡¡½á¹¹Nullable
Êý¾Ý¿âÖеÄÊý×ֺͱà³ÌÓïÑÔÖеÄÊý×ÖÓÐÏÔÖø²»Í¬µÄÌØÕ÷£¬ÒòΪÊý¾Ý¿âÖеÄÊý×Ö¿ÉÒÔΪ¿Õ£¬C#ÖеÄÊý×Ö²»ÄÜΪ¿Õ¡£Int32ÊÇÒ»¸ö½á¹¹£¬¶ø½á¹¹ÊµÏÖΪֵÀàÐÍ£¬ËùÒÔËü²»ÄÜΪ¿Õ¡£
Ö»ÓÐÔÚÊý¾Ý¿âÖУ¬¶øÇÒ°ÑXMLÊý¾ÝÓ³ÉäÎ