ordenar hora de mayor a menor un list
Publicado por juan (9 intervenciones) el 07/10/2019 07:55:08
espero me puedan ayudar con ordenar la hora
||||||||||||||||||||||||||||||||||||||||||classe||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||||||||||||||||||||||programa||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||classe||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practica3
{
class Agenda
{
public string asunto;
public int hora;
public string descripcion;
public string fecha;
public Agenda(string asunto, int hora, string descripcion, string fecha)
{
this.asunto = asunto;
this.hora = hora;
this.descripcion = descripcion;
this.fecha = fecha;
}
public override string ToString()
{
return "Tiene una cita a las " + hora + " hrs el dia " +fecha + " con el asunto de " + asunto + " que se tiene que tratar " + descripcion+"\n";
}
}
}
|||||||||||||||||||||||||||||||||||||||||||||||programa||||||||||||||||||||||||||||||||||||||||||||||||||
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace practica3
{
public partial class Form1 : Form
{
List<Agenda> agendas = new List<Agenda>();
List<Agenda> listanueva = new List<Agenda>();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (textBoxasunto.Text != "" && textBoxfecha.Text != "" && textBoxhora.Text != "" && textBoxdescripcion.Text != "")
{
string asunto = textBoxasunto.Text;
int hora = Int32.Parse(textBoxhora.Text);
string descripcion = textBoxdescripcion.Text;
string fecha = textBoxfecha.Text;
Agenda ag = new Agenda(asunto, hora, descripcion, fecha);
agendas.Add(ag);
textBoxdescripcion.Clear();
textBoxfecha.Clear();
textBoxhora.Clear();
textBoxasunto.Clear();
}
else
{
MessageBox.Show("No puede estar vacia ninguna casilla");
}
}
private void buttonbuscar_Click(object sender, EventArgs e)
{
string salida = "";
int max = 1;
bool encontrado = false;
List<Agenda> listanueva = new List<Agenda>();
for(int i=0; i< agendas.Count; i++)
{
if(agendas[i].fecha == textBoxfechasalida.Text )
{
listanueva.Add(agendas[i]);
}
}
foreach (var a in listanueva)
{
salida += a.ToString();
}
MessageBox.Show(salida);
}
}
Valora esta pregunta


0