<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7924680477145537243</id><updated>2024-08-28T19:38:07.133-07:00</updated><title type='text'>Dicas e soluções .net</title><subtitle type='html'>Este blog tem a finalidade de auxiliar desenvolvedores da plataforma .net com dicas e soluções de problemas.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dicasesolucoesdotnet.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7924680477145537243/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://dicasesolucoesdotnet.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Rafael Bertoni</name><uri>http://www.blogger.com/profile/06272358532560681217</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7924680477145537243.post-8715798006335904544</id><published>2011-01-30T15:59:00.000-08:00</published><updated>2011-01-30T15:59:26.185-08:00</updated><title type='text'>Serialização de objetos</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;Serializar um objeto consiste em poder armazenar os dados contidos dentro deste objeto em arquivos binários, xml, txt e etc. Este recurso é bastante utilizado quando necessitamos gravar informações em disco. A seguir iremos demostrar como guardar uma lista de objetos em um arquivo xml e como recuperar estes dados.&lt;/div&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; text-align: justify;&quot;&gt;Primeiramente iremos criar uma classe Cliente com as propriedades Nome, IDCliente, Idade, Endereco e Email. Esta classe para que seja possível a serialização, iremos adicionar [Serializable] logo acima da declaração da classe conforme imagem abaixo.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilByA0ixGFBX3VKkiXMDTNQQI0dNXkj5ytl5Lyz8lKdUF2HPL1RoveQF91WnoykacY9RjyrGlP_Pf5YqyD12fIQMFiiJ8vcnohkn5ZYmO3FhON05XfkIdyDSEqOgjX-e0hTLd974LocIxU/s1600/2post1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;262&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilByA0ixGFBX3VKkiXMDTNQQI0dNXkj5ytl5Lyz8lKdUF2HPL1RoveQF91WnoykacY9RjyrGlP_Pf5YqyD12fIQMFiiJ8vcnohkn5ZYmO3FhON05XfkIdyDSEqOgjX-e0hTLd974LocIxU/s320/2post1.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;No botão serializar iremos montar uma lista do tipo Cliente e popular com 3 dados de clientes. Em seguida iremos verificar se o arquivo cliente.xml já existe e caso já exista iremos deletá-lo. Iremos utilizar a classe XMLSerializer para serializar o objeto e gerar o arquivo xml com os dados conforme imagem a seguir.﻿&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd4-39gQx1va2yAQ9-sv8hnzKzbEipTK5pnStnWBcuttQO_8hnrFYHRLKk7JhoKvP6z_fb8wXO5yd6L1wurqssnzyMCKiRBYKtWIlh3WNIH3ziT5H6Nufvl9kv6KMzeIHOCOdBcslWcwiY/s1600/2post2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;315&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd4-39gQx1va2yAQ9-sv8hnzKzbEipTK5pnStnWBcuttQO_8hnrFYHRLKk7JhoKvP6z_fb8wXO5yd6L1wurqssnzyMCKiRBYKtWIlh3WNIH3ziT5H6Nufvl9kv6KMzeIHOCOdBcslWcwiY/s400/2post2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: justify;&quot;&gt;Após executar o evento de click do botão serializar,irá gerar o arquivo xml com as propriedades da classe Cliente e os dados adicionados conforme a seguir.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoXvR5tZVTUW-fWfpk3Lgt6F5NG9Wc2-1iCsyMki4n-cTUN3Nk8ro3eGKuh-5L1CZed_sabxLpSNYh7UuxXBE75OrqvdQjyxNPm-pYfAEO0pOTgA-8omapG5DlVX5SJU0s0T8bhXYuVsFt/s1600/2post4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;183&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoXvR5tZVTUW-fWfpk3Lgt6F5NG9Wc2-1iCsyMki4n-cTUN3Nk8ro3eGKuh-5L1CZed_sabxLpSNYh7UuxXBE75OrqvdQjyxNPm-pYfAEO0pOTgA-8omapG5DlVX5SJU0s0T8bhXYuVsFt/s400/2post4.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: justify;&quot;&gt;Utilizando novamente a classe XMLSerializer, iremos deserializar o arquivo xml, recuperando os dados e montando uma lista do tipo Cliente novamente.﻿&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTRgeyNZuvMYF04Iu5cWpWg_jFPfqrUJewjce1zoWXCUrf7rcKGdzOEBsiRFsIww4pnodd3FqOcWc1C263_YPcJudN-dM_zhZ41c7vVDEYvVcPqRWRPLqz9c4wYyW0M5Hql_B_39vRJ2tP/s1600/2post3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;170&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTRgeyNZuvMYF04Iu5cWpWg_jFPfqrUJewjce1zoWXCUrf7rcKGdzOEBsiRFsIww4pnodd3FqOcWc1C263_YPcJudN-dM_zhZ41c7vVDEYvVcPqRWRPLqz9c4wYyW0M5Hql_B_39vRJ2tP/s400/2post3.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Após executar o click do botão deserializar, irá recuperar os dados e a lista será adicionada em uma grid view apresentando na tela os dados que estavam no xml.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfXtBTPPjD0QKkeHw7wdfUwXHOc3gIStf7T4vcqqBNgQkx1g8Km10E-X1JKcQfh1iVguetFDjxl17e_mwkiAYOU678izq0_27pbv2o7Wjp1-RdGdPDRDeTvp8plg0_xKrwmR1_7mW-dUFl/s1600/2post5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;158&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfXtBTPPjD0QKkeHw7wdfUwXHOc3gIStf7T4vcqqBNgQkx1g8Km10E-X1JKcQfh1iVguetFDjxl17e_mwkiAYOU678izq0_27pbv2o7Wjp1-RdGdPDRDeTvp8plg0_xKrwmR1_7mW-dUFl/s400/2post5.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;Agora, iremos adicionar [XmlIgnoreAttribute] na propriedade Endereco e isso fará com que esta propriedade seja ignorada no momento de serializar o objeto e não irá adicionar esta propriedade no xml.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizxjokx_VP7S50h8Dae_f6sPn_U9Xni-ExwAva9wyhMvIG_o7D8qi0Vq8HZB21lN3Yp3ayItYMaeYgrj6ab5BEtwEcdR0BWysNke8Gy_vpPWrLRW9OBQ2NzYGyCihEotAaHI7tTOZBvea_/s1600/2post6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;242&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizxjokx_VP7S50h8Dae_f6sPn_U9Xni-ExwAva9wyhMvIG_o7D8qi0Vq8HZB21lN3Yp3ayItYMaeYgrj6ab5BEtwEcdR0BWysNke8Gy_vpPWrLRW9OBQ2NzYGyCihEotAaHI7tTOZBvea_/s320/2post6.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;Após executar novamente o click do botão serializar, veja na imagem abaixo que não foi adicionada a propriedade Endereco no xml.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF4crEn6MKu1qkr0rQMVSX98DMMKPR7WSEn9pTU0Z39ekJHLvmRkw7hkownRTkmWmjiuGoVuIXx8aI7Qp-lUWN-oZqS1X9cV1DRl0u6-lFkYRH1lGejRvDpnNFJnoSg81Dw8ENeIzlFd9J/s1600/2post7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;162&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgF4crEn6MKu1qkr0rQMVSX98DMMKPR7WSEn9pTU0Z39ekJHLvmRkw7hkownRTkmWmjiuGoVuIXx8aI7Qp-lUWN-oZqS1X9cV1DRl0u6-lFkYRH1lGejRvDpnNFJnoSg81Dw8ENeIzlFd9J/s400/2post7.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: justify;&quot;&gt;Após executar novamente o click do botão deserializar, será recuperado os dados do xml e adicionados na grid view, porém o campo endereço estará vazio, pois não foi salvo no momento da serialização.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5bK-d9DfnSPXNz7p0smijsaSXt7XRxfMlv3wA2WiHJumFdNn9fqG6EulUEgl2iAO4uhSNZ54KKPIlFSkMVujvIhEVQe5WCWqJKzV_v9YNDTthtbsOcvs4aoL1j6cEidlWMthcycTrNTbw/s1600/2post8.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; s5=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5bK-d9DfnSPXNz7p0smijsaSXt7XRxfMlv3wA2WiHJumFdNn9fqG6EulUEgl2iAO4uhSNZ54KKPIlFSkMVujvIhEVQe5WCWqJKzV_v9YNDTthtbsOcvs4aoL1j6cEidlWMthcycTrNTbw/s400/2post8.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;﻿&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dicasesolucoesdotnet.blogspot.com/feeds/8715798006335904544/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://dicasesolucoesdotnet.blogspot.com/2011/01/serializacao-de-objetos.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7924680477145537243/posts/default/8715798006335904544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7924680477145537243/posts/default/8715798006335904544'/><link rel='alternate' type='text/html' href='http://dicasesolucoesdotnet.blogspot.com/2011/01/serializacao-de-objetos.html' title='Serialização de objetos'/><author><name>Rafael Bertoni</name><uri>http://www.blogger.com/profile/06272358532560681217</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilByA0ixGFBX3VKkiXMDTNQQI0dNXkj5ytl5Lyz8lKdUF2HPL1RoveQF91WnoykacY9RjyrGlP_Pf5YqyD12fIQMFiiJ8vcnohkn5ZYmO3FhON05XfkIdyDSEqOgjX-e0hTLd974LocIxU/s72-c/2post1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7924680477145537243.post-679331803877886915</id><published>2011-01-17T17:30:00.000-08:00</published><updated>2011-01-18T17:21:52.474-08:00</updated><title type='text'>Utilizando método Sort da classe List</title><content type='html'>Neste tópico iremos abordar sobre o método Sort da classe List. Este método é utilizado para realizarmos ordenações dos&amp;nbsp;objetos contidos dentro de uma lista.&lt;br /&gt;
Para utilizarmos este método, precisamos primeiramente ter as informações. Vamos criar uma página com&amp;nbsp;um controle ListBox, 1 botão para ordenar de forma crescente e outro para ordenar de forma decrescente.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaaj99ZXxiGwxjpNOHDLq-9DlVijRYQt-H1TPZMvnLfXsHTcdfBN_mIWO1_WWKX4JbETzZOe_qB245qHPoKe9nVE8MdKFpp-cHXBnohDnhyphenhyphen1ykHemRvysykBgfrhoqBuxaBtrH4MzmrMA0/s1600/1post0%2528novo%2529.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Controles da página aspx&quot; border=&quot;0&quot; height=&quot;175&quot; n4=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaaj99ZXxiGwxjpNOHDLq-9DlVijRYQt-H1TPZMvnLfXsHTcdfBN_mIWO1_WWKX4JbETzZOe_qB245qHPoKe9nVE8MdKFpp-cHXBnohDnhyphenhyphen1ykHemRvysykBgfrhoqBuxaBtrH4MzmrMA0/s400/1post0%2528novo%2529.jpg&quot; title=&quot;Controles da página aspx&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Criado os controles ao carregar a página iremos popular o ListBox com nomes de clientes.﻿&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVnZwGTlwjMKkKHrTQPcFdfaH1nIW5iTw_vb6l_IaQoZuvF8GJvx3r8o619FBQzgMue0tj2oh4NSA_CnOlagscjgEMvyDTZ92KQ4cdPXEuYo7lp6y7F90oCHBYOePvlyQk-_SoCXiDYWmD/s1600/1post1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Adicionando nomes ao listbox&quot; border=&quot;0&quot; height=&quot;162&quot; n4=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVnZwGTlwjMKkKHrTQPcFdfaH1nIW5iTw_vb6l_IaQoZuvF8GJvx3r8o619FBQzgMue0tj2oh4NSA_CnOlagscjgEMvyDTZ92KQ4cdPXEuYo7lp6y7F90oCHBYOePvlyQk-_SoCXiDYWmD/s320/1post1.jpg&quot; title=&quot;Adicionando nomes ao listbox&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Ao executar a página estará da seguinte forma:﻿&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrkp3uN1FkhIjGi8Cfai3kFesFnQePkYob3KpircXHffrQmBhQVWUr1jtMLmCnG4kS7JJ5QMEC2Oa8oEfqFMnA9440bPMVXvNbPF0Bzftmz8ku0HIeafOz_30AB3Qi9cfIXpCTNbmjxecb/s1600/1post2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Página com lista de nomes desordenada&quot; border=&quot;0&quot; height=&quot;201&quot; n4=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrkp3uN1FkhIjGi8Cfai3kFesFnQePkYob3KpircXHffrQmBhQVWUr1jtMLmCnG4kS7JJ5QMEC2Oa8oEfqFMnA9440bPMVXvNbPF0Bzftmz8ku0HIeafOz_30AB3Qi9cfIXpCTNbmjxecb/s320/1post2.jpg&quot; title=&quot;Página com lista de nomes desordenada&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Criaremos uma classe chamada Cliente e nela adicionaremos 2 propriedades para serem populadas no objeto: Nome e IDCliente.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqhHQmFUIDfTGg4DT6BLPNkyqtbkmbjaexKLyZ4BeCW-wmv2V137VyVyAw1T79JNvJXXIBH152fOx-hT1k_qbTj3Q0TLErAGJ_lgVg0QVKn5vxuh7ClzaJI1bXvtS1EIk3VMa-fzQYU_3i/s1600/1post7.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Classe cliente com as propriedades do objeto&quot; border=&quot;0&quot; height=&quot;311&quot; n4=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqhHQmFUIDfTGg4DT6BLPNkyqtbkmbjaexKLyZ4BeCW-wmv2V137VyVyAw1T79JNvJXXIBH152fOx-hT1k_qbTj3Q0TLErAGJ_lgVg0QVKn5vxuh7ClzaJI1bXvtS1EIk3VMa-fzQYU_3i/s320/1post7.jpg&quot; title=&quot;Classe cliente com as propriedades do objeto&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Ao clicar no botão ordenar crescente será executado o&amp;nbsp;código a seguir, onde após recuperar os nomes do ListBox e montar uma lista do objeto cliente, será chamado método Sort onde irá realizar as comparações e fazer a ordenação e após a ordenação irá atualizar o ListBox com a nova lista.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2PpizKd5ELphCk9Rx3xWKJobKthULHGxIqd1DfmXtab82lyWFdUFw_v7yGvpfHsR7hHh3jEWSlTL5tUn63kpSTRxlf5ofG7Ui4iuZRN06nEdrE3zPkUsoXIVbDKNKJz_PCBu86LhjHvp2/s1600/1post3%2528Crescente%2529.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Utilizando o método sort para ordenação crescente&quot; border=&quot;0&quot; height=&quot;248&quot; n4=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2PpizKd5ELphCk9Rx3xWKJobKthULHGxIqd1DfmXtab82lyWFdUFw_v7yGvpfHsR7hHh3jEWSlTL5tUn63kpSTRxlf5ofG7Ui4iuZRN06nEdrE3zPkUsoXIVbDKNKJz_PCBu86LhjHvp2/s320/1post3%2528Crescente%2529.jpg&quot; title=&quot;Utilizando o método sort para ordenação crescente&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align=&quot;center&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;/div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Após a execução deste trecho de código, os nomes estarão ordenados em ordem crescente.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRzKCq9moycWLU6Mb6ZSK7244moYC5CmxWOBgSAuaKxvLCowbOCLhjT9_nZ4MNLYRfQPuh8j8cColMdoCrjTcGepMWPwTpYKWHkPG7Ls-86gZGezWxjaejeUVSGfbWDLIeKHlDIUvkHGmn/s1600/1post4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Página com lista ordenada crescente&quot; border=&quot;0&quot; height=&quot;188&quot; n4=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRzKCq9moycWLU6Mb6ZSK7244moYC5CmxWOBgSAuaKxvLCowbOCLhjT9_nZ4MNLYRfQPuh8j8cColMdoCrjTcGepMWPwTpYKWHkPG7Ls-86gZGezWxjaejeUVSGfbWDLIeKHlDIUvkHGmn/s320/1post4.jpg&quot; title=&quot;Página com lista ordenada crescente&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Ao clicar no botão ordenar decrescente será executado o&amp;nbsp;código a seguir, onde é quase igual ao de ordenação crescente, porém&amp;nbsp;para que faça a ordenação decrescente apenas será invertida a comparação ao chamar o método Sort,ao invés de cliente1.Nome.CompareTo(cliente2.Nome), será cliente2.Nome.CompareTo(cliente1.Nome).&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqAZOXdjr9Y5I7jMo61PcSE2sTkw4889CopMbPTBitTjBR7Jj6OjVEAOUGGcgGbCAhHIQQRJksLNGnu08CK_w-e5cxI7t26PqD57bxqXpJehQRyGxGuExaxjmc1JmXvZzMHUzOFeT9g1uP/s1600/1post5%2528Crescente%2529.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Utilizando o método sort para ordenação decrescente&quot; border=&quot;0&quot; height=&quot;310&quot; n4=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqAZOXdjr9Y5I7jMo61PcSE2sTkw4889CopMbPTBitTjBR7Jj6OjVEAOUGGcgGbCAhHIQQRJksLNGnu08CK_w-e5cxI7t26PqD57bxqXpJehQRyGxGuExaxjmc1JmXvZzMHUzOFeT9g1uP/s400/1post5%2528Crescente%2529.jpg&quot; title=&quot;Utilizando o método sort para ordenação decrescente&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Após a execução deste trecho de código, os nomes estarão ordenados em ordem decrescente.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6PYOitaWG4BeNvLapDx303wQdG6-g0ONixYlLD5J90BMD2UBtAbJk3F1fV6Qglys7wkzTzOxQoq8q7546fmqycfOJ-WmtY6We1rgTRQbPdJ3-2_lvvexIfF8TUKEg6WQWFS-JJ4vV9Z3t/s1600/1post6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Página com lista ordenada decrescente&quot; border=&quot;0&quot; com=&quot;&quot; height=&quot;188&quot; lista=&quot;&quot; n4=&quot;true&quot; ordenada=&quot;&quot; página=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6PYOitaWG4BeNvLapDx303wQdG6-g0ONixYlLD5J90BMD2UBtAbJk3F1fV6Qglys7wkzTzOxQoq8q7546fmqycfOJ-WmtY6We1rgTRQbPdJ3-2_lvvexIfF8TUKEg6WQWFS-JJ4vV9Z3t/s320/1post6.jpg&quot; title=&quot;Página com lista ordenada decrescente&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dicasesolucoesdotnet.blogspot.com/feeds/679331803877886915/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://dicasesolucoesdotnet.blogspot.com/2011/01/utilizando-metodo-sort-da-classe-list.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7924680477145537243/posts/default/679331803877886915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7924680477145537243/posts/default/679331803877886915'/><link rel='alternate' type='text/html' href='http://dicasesolucoesdotnet.blogspot.com/2011/01/utilizando-metodo-sort-da-classe-list.html' title='Utilizando método Sort da classe List'/><author><name>Rafael Bertoni</name><uri>http://www.blogger.com/profile/06272358532560681217</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaaj99ZXxiGwxjpNOHDLq-9DlVijRYQt-H1TPZMvnLfXsHTcdfBN_mIWO1_WWKX4JbETzZOe_qB245qHPoKe9nVE8MdKFpp-cHXBnohDnhyphenhyphen1ykHemRvysykBgfrhoqBuxaBtrH4MzmrMA0/s72-c/1post0%2528novo%2529.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>