GoConqr has a new look! Let us know what you think.

Notes

Implementar Leitura em disco

Luiz Cardamone Portuguese 1 page

Content of the notes (1)

Page 1

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.IO;

using Exercicos;

namespace ConsoleApp6

{

class RepositorioDisco

{

private static int _id = 0;

public static void Add(string nome, int idade)

{

_id++;

var add = new Pessoa(_id, nome, idade);

using (StreamWriter _escreverEmDisco = new StreamWriter("BaseRepositorio.txt", append: true))

{

_escreverEmDisco.Write(add.Id + "%" + add.Nome + "%" + add.Idade + "\r\n");

}

}

public static void Listar()

{

List<string> StrLinhas = new List<string>();

using (StreamReader LerDisco = new StreamReader("BaseRepositorio.txt"))

{

while (!LerDisco.EndOfStream)

{

StrLinhas.Add(LerDisco.ReadLine());

}

for (int i = 0; i < StrLinhas.Count; i++)

{

string[] _separador = StrLinhas[i].Split('&');

Console.WriteLine(_separador[0] + " " + _separador[1] + " " + _separador[2]);

}

}

}

public static void Excluir(int id)

{

//for (int i = 0; i < Pessoas.Count; i++)

//{

// //if (Pessoas[i].Id == id)

// //{

// // Pessoas.RemoveAt(i);

// // Console.Write($"\n A Exclusão do codigo {id} foi realizada com sucesso !");

// // break;

// //}

// //else if ((i + 1) == Pessoas.Count)

// //{

// // Mensage_De_Erro.Exclusao_sem_correspondecia(id);

// //}

//}

}

}

}

Information

Description
Note on Implementar Leitura em disco, created by Luiz Cardamone on 23/08/2019.
Created by
Luiz Cardamone
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?