
02/09/2011, 23:47
|
| | Fecha de Ingreso: septiembre-2006 Ubicación: Buenos Aires
Mensajes: 132
Antigüedad: 18 años, 6 meses Puntos: 0 | |
Ordenar un generic list(of T) Hola!!
Alguien sabe el codigo para poder ordenar el list por "action", necesitaria obtener el mismo List pero ordenado por action
gracias!!
Código:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="VB" runat="server">
Public CabinetComun As List(Of CounterStrikeInfo) = New List(Of CounterStrikeInfo)
Public Class CounterStrikeInfo
Public User As String
Public Action As String
Public HowMany As Integer
Public Victim As String
Public Gun As String
Public Sub New(ByVal m_User As String, ByVal m_Action As String, _
ByVal m_HowMany As Integer, ByVal m_Victim As String, ByVal m_Gun As String)
User = m_User
Action = m_Action
HowMany = m_HowMany
Victim = m_Victim
Gun = m_Gun
End Sub
End Class
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
CabinetComun.Add(New CounterStrikeInfo("john", "headshot", 1, "bruce", "gun"))
CabinetComun.Add(New CounterStrikeInfo("edward", "headshot", 1, "eddie", "machinegun"))
CabinetComun.Add(New CounterStrikeInfo("edward", "killed", 1, "eddie", "machinegun"))
CabinetComun.Add(New CounterStrikeInfo("edward", "left the game", 1, "", ""))
CabinetComun.Add(New CounterStrikeInfo("edward", "entered the game", 1, "", ""))
CabinetComun.ForEach(AddressOf displayCounterStrikeInfo)
End Sub
Sub displayCounterStrikeInfo(ByVal b As CounterStrikeInfo)
myLabel.Text += "How many: " & b.HowMany & " - " _
& "User: " & b.User & " - " _
& "Action: " & b.Action & " - " _
& "Victim: " & b.Victim & " - " _
& "Gun: " & b.Gun & "<br/>"
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:label ID="myLabel" runat="server"></asp:label>
</div>
</form>
</body>
</html>
|