コード例 #1
0
ファイル: Program.cs プロジェクト: MathPB/Aulas
        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();
                }
            }
        }
コード例 #2
0
        private static void CarregarContas()
        {
            using (LeitorDeArquivo leitor = new LeitorDeArquivo("texte.txt"))
            {
                leitor.LerProximaLinha();
            }
            //LeitorDeArquivo leitor = null;
            //try
            //{
            //    leitor = new LeitorDeArquivo("contas.txt");

            //    leitor.LerProximaLinha();
            //}
            //finally
            //{
            //    Console.WriteLine("Executando o finally");
            //    if(leitor != null) leitor.Fechar();
            //}
        }
コード例 #3
0
        private static void CarregarContas()
        {
            using (LeitorDeArquivo leitor = new LeitorDeArquivo("contas.txt"))
            {
                leitor.LerProximaLinha();
            }

            // --------------------
            //LeitorDeArquivo leitor = null;
            //try
            //{
            //    leitor = new LeitorDeArquivo("contas.txt");
            //    leitor.LerProximaLinha();
            //    leitor.LerProximaLinha();
            //}
            //finally
            //{
            //    if (leitor != null)
            //    {
            //        leitor.Fechar();
            //    }
            //}
        }
コード例 #4
0
        private static void CarregarContas()
        {
            using (LeitorDeArquivo leitor = new LeitorDeArquivo("texte.txt"))
            {
                leitor.LerProximaLinha();
            }

            //----- | Try / Catch / Finally | ----- \\
            //LeitorDeArquivo leitor = null;
            //try
            //{
            //    leitor = new LeitorDeArquivo("contas.txt");
            //    leitor.LerProximaLinha();
            //}
            //catch (IOException)
            //{
            //    Console.WriteLine("Exceção do tipo IOException capturada e tratada");
            //}
            //finally
            //{
            //    if (leitor != null)
            //        leitor.Fechar();
            //}
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: ThalitaFR/Cursos-Csharp
        private static void CarregarContas()
        {
            using (LeitorDeArquivo leitor = new LeitorDeArquivo("teste.txt"))
            {
                leitor.LerProximaLinha();
            }


            //-----------------------------------------------------------------------------
            //LeitorDeArquivo leitor = null;

            //// O try pode ter só catch ou só finally e também os dois.
            //try
            //{
            //    leitor =  new LeitorDeArquivo("contasl.txt");

            //    leitor.LerProximaLinha();
            //    leitor.LerProximaLinha();
            //    leitor.LerProximaLinha();

            //}
            //catch (IOException)
            //{
            //    Console.WriteLine("Exceção do tipo IOException Capturada e Tratada");
            //}
            //// Finally executa acontecendo ou nao uma exceção.
            //finally
            //{
            //    Console.WriteLine("Executando o Finally");
            //    if(leitor != null)
            //    {
            //        leitor.Fechar();
            //    }

            //}
        }