GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Notizen

Implementar Leitura em disco

Luiz Cardamone Portugiesisch 1 Seite

Inhalt der Notizen (1)

Seite 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);

// //}

//}

}

}

}

Informationen

Beschreibung
Notiz am Implementar Leitura em disco, erstellt von Luiz Cardamone am 23/08/2019.
Erstellt von
Luiz Cardamone
Aufrufe
1
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck