/
Proceso.cs
105 lines (79 loc) · 1.97 KB
/
Proceso.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System.IO;
using System.Collections;
using System;
namespace Practica4
{
public class Proceso
{
private ArrayList Personas = new ArrayList();
private Proceso persona = new Registro();
public Proceso()
{
Personas = new ArrayList();
persona = new Registro();
}
public void Ejecutar()
{
leer();
IRegistros();
}
public void leer(){
string ruta;
try
{
Console.WriteLine("Dame el archivo a leer");
ruta = Console.ReadLine();
StreamReader objReader = new StreamReader(ruta);
string sLine= objReader.ReadLine();
ArrayList arrText = new ArrayList();
while (sLine != null)
{
ARegistro(sLine);
sLine = objReader.ReadLine();
}
objReader.Close();
}
catch(Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
finally
{
Console.WriteLine("Cerrando la lectura.");
}
}
public void ARegistro(string sLine)
{
char[] delimiterChars = {','};
string[] words = sLine.Split(delimiterChars);
Proceso persona = new Proceso();
persona.id = words[0];
persona.nombre = words[1];
persona.domicilio = words[2];
persona.telefono = words [3];
Personas.Add(persona);
}
public void IRegistros()
{
Console.WriteLine("Numero de registros: "+Personas.Count);
foreach (object Registro in Personas)
{
this.persona = (Proceso) Registro;
ITodo();
}
}
public void ITodo()
{
Console.WriteLine("----------------------------------------");
Console.Write("ID:");
Console.WriteLine(this.persona.id);
Console.Write("Nombre:");
Console.WriteLine(this.persona.nombre);
Console.Write("Telefono:");
Console.WriteLine(this.persona.nombre);
Console.Write("Domicilio:");
Console.WriteLine(this.persona.domicilio);
Console.WriteLine("----------------------------------------");
}
}
}