°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ticket¡¡is¡¡converted¡¡into¡¡a¡¡binary¡¡stream£»¡¡the¡¡programmer¡¡does¡¡not¡¡need¡¡to¡¡do¡¡anything¡¡other¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡than¡¡pass¡¡an¡¡instance¡¡to¡¡the¡¡data¡¡stream¡£¡¡The¡¡data¡¡stream¡¡libraries¡¡handle¡¡all¡¡of¡¡the¡¡other¡¡details¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡In¡¡the¡¡declaration¡¡of¡¡Ticket£»¡¡the¡¡parameterless¡¡constructor¡¡has¡¡been¡¡bolded¡¡to¡¡emphasize¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡that¡¡this¡¡type¡¡of¡¡constructor¡¡is¡¡necessary¡¡when¡¡converting¡¡a¡¡data¡¡stream¡¡into¡¡an¡¡object¡¡instance¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡When¡¡binary¡¡streams¡¡restore¡¡types£»¡¡they¡¡instantiate¡¡an¡¡empty¡¡object¡¡and¡¡then¡¡assign¡¡the¡¡data¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡members¡£¡¡Thus£»¡¡when¡¡an¡¡object¡¡is¡¡created£»¡¡a¡¡parameterless¡¡constructor¡¡is¡¡needed¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Converting¡¡a¡¡Text¡¡Stream¡¡into¡¡a¡¡Binary¡¡Stream¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡To¡¡convert¡¡the¡¡stream¡¡from¡¡text¡¡to¡¡binary¡¡involves¡¡breaking¡¡apart¡¡the¡¡text¡¡stream£»¡¡instantiating¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a¡¡Ticket¡¡instance£»¡¡assigning¡¡the¡¡data¡¡members£»¡¡and¡¡saving¡¡the¡¡instance¡¡to¡¡the¡¡binary¡¡stream¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡All¡¡of¡¡these¡¡steps¡¡are¡¡performed¡¡in¡¡the¡¡following¡¡source¡¡code¡¡£¨you¡¯ll¡¡need¡¡a¡¡reference¡¡to¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡LottoLibrary¡¡in¡¡Text2Binary£©¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Imports¡¡System¡£IO¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Imports¡¡System¡£Runtime¡£Serialization¡£Formatters¡£Binary¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Imports¡¡System¡£Text¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Class¡¡LottoTicketProcessor¡¡£º¡¡Implements¡¡IText2BinaryProcessor¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Process£¨ByVal¡¡reader¡¡As¡¡TextReader£»¡¡ByVal¡¡writer¡¡As¡¡Stream£©¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡IText2BinaryProcessor¡£Process¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡retval¡¡As¡¡StringBuilder¡¡=¡¡New¡¡StringBuilder£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Do¡¡While¡¡reader¡£Peek£¨£©¡¡¡¡¡1¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡lineOfText¡¡As¡¡String¡¡=¡¡reader¡£ReadLine£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡splitUpText¡¡As¡¡String£¨£©=¡¡lineOfText¡£Split£¨New¡¡Char£¨£©¡¡£û¡¨¡¡¡¨c£ý£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡dateSplit¡¡As¡¡String£¨£©¡¡=¡¡splitUpText£¨0£©¡£Split£¨New¡¡Char£¨£©¡¡£û¡¨¡£¡¨c£ý£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡ticket¡¡As¡¡LottoLibrary¡£Ticket¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡New¡¡LottoLibrary¡£Ticket£¨¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡New¡¡DateTime£¨¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨dateSplit£¨0£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨dateSplit£¨1£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨dateSplit£¨2£©£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡297¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡A¡¡PT¡¡E¡¡R¡¡¡¡¡¡1¡¡0¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡I¡¡N¡¡G¡¡¡¡¡¡A¡¡B¡¡O¡¡U¡¡T¡¡¡¡P¡¡E¡¡R¡¡S¡¡IS¡¡T¡¡E¡¡N¡¡CE¡¡275¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡New¡¡Integer£¨£©¡¡£û¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨splitUpText£¨1£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨splitUpText£¨2£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨splitUpText£¨3£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨splitUpText£¨4£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨splitUpText£¨5£©£©£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨splitUpText£¨6£©£©¡¡£ý£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Integer¡£Parse£¨splitUpText£¨7£©£©£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡formatter¡¡As¡¡BinaryFormatter¡¡=¡¡New¡¡BinaryFormatter£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡formatter¡£Serialize£¨writer£»¡¡ticket£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Loop¡¡
¡¡¡¡¡¡¡¡End¡¡Sub¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡The¡¡code¡¡splits¡¡the¡¡text¡¡stream¡¡by¡¡reading¡¡a¡¡line¡¡of¡¡text¡¡and¡¡then¡¡splitting¡¡apart¡¡the¡¡fields¡£¡¡¡¡
The¡¡split¡apart¡¡fields¡¡are¡¡then¡¡converted¡¡into¡¡numbers¡¡by¡¡using¡¡the¡¡¡¡Integer¡£Parse£¨£©¡¡method¡£¡¡¡¡
This¡¡process¡¡of¡¡splitting¡¡and¡¡conversion¡¡is¡¡called¡¡marshaling¡¡data¡£¡¡Marshaling¡¡is¡¡a¡¡technical¡¡¡¡
term¡¡that¡¡means¡¡to¡¡convert¡¡a¡¡type¡¡from¡¡one¡¡medium¡¡to¡¡another¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡We¡¡manage¡¡the¡¡text¡¡marshaling£»¡¡but¡¡¡¡manages¡¡the¡¡binary¡¡marshaling£»¡¡which¡¡is¡¡still¡¡there¡¡¡¡
behind¡¡the¡¡scenes¡£¡¡The¡¡System¡£Runtime¡£Serialization¡£Formatters¡£Binary¡£BinaryFormatter¡¡type¡¡¡¡
manages¡¡marshaling¡¡of¡¡the¡¡Ticket¡¡instance¡¡to¡¡the¡¡binary¡¡stream¡£¡¡The¡¡¡¡Serializable¡¡attribute¡¡¡¡
is¡¡used¡¡by¡¡the¡¡BinaryFormatter¡¡as¡¡an¡¡indicator¡¡that¡¡the¡¡Ticket¡¡type¡¡is¡¡allowed¡¡to¡¡be¡¡serialized¡¡and¡¡¡¡
deserialized¡£¡¡In¡¡essence£»¡¡converting¡¡from¡¡a¡¡text¡¡stream¡¡to¡¡a¡¡binary¡¡stream¡¡means¡¡to¡¡marshal¡¡a¡¡¡¡
text¡defined¡¡ticket¡¡into¡¡a¡¡¡defined¡¡ticket£»¡¡and¡¡that¡¡is¡¡then¡¡marshaled¡¡into¡¡a¡¡binary¡defined¡¡¡¡
ticket¡£¡¡¡¡
Converting¡¡a¡¡Binary¡¡Stream¡¡into¡¡a¡¡Text¡¡Stream¡¡
Converting¡¡a¡¡binary¡¡stream¡¡into¡¡a¡¡text¡¡stream¡¡involves¡¡using¡¡the¡¡¡provided¡¡formatter¡¡to¡¡¡¡
create¡¡a¡¡Ticket¡¡instance¡¡that¡¡is¡¡then¡¡converted¡¡into¡¡text¡£¡¡The¡¡following¡¡is¡¡the¡¡plete¡¡source¡¡¡¡
code¡¡£¨you¡¯ll¡¡need¡¡a¡¡reference¡¡to¡¡¡¡LottoLibrary¡¡in¡¡¡¡Binary2Text£©¡£¡¡
Imports¡¡System¡£IO¡¡
Imports¡¡System¡£Runtime¡£Serialization¡£Formatters¡£Binary¡¡
Public¡¡Class¡¡LottoTicketProcessor¡¡£º¡¡Implements¡¡IBinary2TextProcessor¡¡
¡¡¡¡¡¡¡¡Public¡¡Sub¡¡Process£¨ByVal¡¡input¡¡As¡¡Stream£»¡¡ByVal¡¡output¡¡As¡¡TextWriter£©¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡Implements¡¡IBinary2TextProcessor¡£Process¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡builder¡¡As¡¡StringBuilder¡¡=¡¡New¡¡StringBuilder£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Try¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Do¡¡While¡¡True¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡formatter¡¡As¡¡BinaryFormatter¡¡=¡¡New¡¡BinaryFormatter£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Dim¡¡ticket¡¡As¡¡LottoLibrary¡£Ticket¡¡=¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡DirectCast£¨formatter¡£Deserialize£¨input£©£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡LottoLibrary¡£Ticket£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡298¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
276¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡1¡¡0¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡I¡¡N¡¡G¡¡¡¡¡¡A¡¡B¡¡OU¡¡T¡¡¡¡¡¡P¡¡E¡¡R¡¡S¡¡IS¡¡TE¡¡N¡¡CE¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡builder¡£AppendFormat£¨¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¨£û0£ý¡££û1£ý¡££û2£ý¡¡£û3£ý¡¡£û4£ý¡¡£û5£ý¡¡£û6£ý¡¡£û7£ý¡¡£û8£ý¡¡£û9£ý¡¡£û10£ý¡¨£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£DrawDate¡£Year£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£DrawDate¡£Month£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£DrawDate¡£Day£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨0£©£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨1£©£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨2£©£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨3£©£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨4£©£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Numbers£¨5£©£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ticket¡£Bonus£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ControlChars¡£NewLine£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Loop¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Catch¡¡e¡¡As¡¡Exception¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Try¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡output¡£Write£¨builder¡£ToString£¨£©£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡In¡¡the¡¡code£»¡¡a¡¡binary¡¡stream¡¡is¡¡read¡¡using¡¡the¡¡BinaryFormatter¡¡class£»¡¡which¡¡reads¡¡the¡¡data¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡for¡¡an¡¡object¡¡from¡¡the¡¡data¡¡stream¡£¡¡Notice¡¡how¡¡the¡¡method¡¡Deserialize£¨£©¡¡does¡¡not¡¡ask¡¡which¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡type¡¡to¡¡read¡£¡¡This¡¡is¡¡because¡¡all¡¡of¡¡that¡¡information¡¡is¡¡saved¡¡in¡¡the¡¡stream¡£¡¡Deserialize£¨£©¡¡will¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡read¡¡data¡¡from¡¡the¡¡stream£»¡¡associate¡¡the¡¡data¡¡with¡¡a¡¡type£»¡¡instantiate¡¡it£»¡¡and¡¡populate¡¡the¡¡data¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡members¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡bolded¡¡code¡¡in¡¡the¡¡preceding¡¡listing¡¡points¡¡out¡¡where¡¡deserialization¡¡bees¡¡tricky£»¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡which¡¡centers¡¡around¡¡when¡¡to¡¡read¡¡what¡¡type¡£¡¡A¡¡binary¡¡stream¡¡when¡¡processed¡¡by¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡BinaryFormatter¡¡will¡¡read¡¡and¡¡write¡¡objects¡£¡¡BinaryFormatter¡¡will¡¡instantiate¡¡whatever¡¡it¡¡encoun
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ters¡¡and¡¡assumes¡¡that¡¡the¡¡caller¡¡of¡¡BinaryFormatter¡¡knows¡¡which¡¡type¡¡is¡¡being¡¡manipulated¡£¡¡If¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡caller¡¡does¡¡not¡¡know¡¡this£»¡¡an¡¡exception¡¡will¡¡occur¡¡because¡¡the¡¡type¡¡cast¡¡to¡¡the¡¡specific¡¡type¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡will¡¡fail¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡exception¡¡block¡¡is¡¡necessary¡¡because¡¡you¡¡don¡¯t¡¡know¡¡how¡¡many¡¡Ticket¡¡objects¡¡have¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡been¡¡saved£»¡¡as¡¡the¡¡count¡¡has¡¡not¡¡been¡¡saved¡¡to¡¡the¡¡stream¡£¡¡¡¡provides¡¡the¡¡Position¡¡and¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Length¡¡properties¡¡to¡¡determine¡¡if¡¡any¡¡instances¡¡are¡¡left¡¡to¡¡be¡¡read£»¡¡but¡¡those¡¡properties¡¡work¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡only¡¡with¡¡files¡£¡¡If¡¡the¡¡binary¡¡stream¡¡being¡¡read¡¡is¡¡a¡¡console¡¡data¡¡stream£»¡¡there¡¡is¡¡no¡¡length¡¡or¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡position¡£¡¡Thus£»¡¡the¡¡only¡¡real¡¡solution¡¡is¡¡to¡¡keep¡¡reading¡¡until¡¡you¡¡can¡¯t¡¡do¡¡so¡¡anymore¡¡and¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡assume¡¡processing¡¡is¡¡plete¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡INTENTION¡¡AND¡¡IMPLEMENTATION¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡fact¡¡that¡¡¡¡Position¡¡and¡¡¡¡Length¡¡have¡¡different¡¡behaviors¡¡depending¡¡on¡¡the¡¡implementation¡¡might¡¡seem¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡to¡¡break¡¡the¡¡contract¡¡of¡¡being¡¡able¡¡to¡¡separate¡¡intention¡¡from¡¡implementation¡£¡¡It¡¡seems¡¡to¡¡break¡¡the¡¡po
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡nent¡¡software¡¡paradigm¡¡because£»¡¡as¡¡a¡¡developer£»¡¡you¡¡do¡¡need¡¡to¡¡know¡¡about¡¡the¡¡stream¡¡implementation¡£¡¡The¡¡¡¡
¡¡¡¡¡¡¡¡¡¡