private static void CarregarContasSemUsing() { LeitorDeArquivo leitor = null; try { leitor = new LeitorDeArquivo("contasl.txt"); leitor.LerProximaLinha(); leitor.LerProximaLinha(); leitor.LerProximaLinha(); } //catch (IOException e) //{ // Console.WriteLine("Exceção do tipo IOException capturada e tratada"); //} finally { Console.WriteLine("Executando o finally"); if (leitor != null) { leitor.Fechar(); } } }
private static void CarregarContas() { LeitorDeArquivo leitor = null; try { leitor = new LeitorDeArquivo("contas.txt"); leitor.LerProximaLinha(); leitor.LerProximaLinha(); leitor.LerProximaLinha(); } catch (IOException) { Console.WriteLine("Exceção do tipo IOException capturada e tratada!"); } finally { if (leitor != null) { leitor.Fechar(); } } }