获取数组中的最高和最低数字

时间:2017-02-01 22:08:57

标签: asp.net vb.net

您好我有一个服务台应用程序,我有一个下拉列表,其中填充了类别列表,在用户选择值时,它自动绑定另一个下拉列表,显示分配给每个类别的管理员代理列表。

现在的问题是,如果为一个参与者类别分配了多个管理代理,我希望能够在每个代理之前计算打开票证的总数并获得最低值,并绑定具有最小数量的那个下拉文本的票证。所以不需要用户选择管理代理来分配工作。 继承我的code.pls帮助。

 ------------------category dropdown that binds assigness dropdown-----------
  Protected Sub ddlcategory_SelectedIndexChanged(sender As Object, e As EventArgs)
        Dim TK As GHD5.TicketCategory = (New cls_ticketcategories).SelectThisID(ddlcategory.SelectedValue)
        mod_filldropdowns.FillAssignees(ddlassignee, TK.CategoryID)
        If ddlassignee.Items.Count = 0 Then
            Msgbox1.ShowHelp("No Agent for " & ddlcategory.SelectedValue & "")
            'ElseIf ddlassignee.Items.Count > 1 Then
            '    For Each rec As GHD5.User In ddlassignee.Items
            '       select * from tickets where status is 'open' and assigne = list of assigness
                    count()
                   get lowest number in each record retun
bind dropdown with assignee username

            '    Next
            Exit Sub

        End If
    End Sub


-------code to fill assigness dropdown based on category ID selected-----------------

   Public Sub FillAssignees(ByVal cb As ASPxComboBox, ByVal categoryid As Integer)
        Dim obj As List(Of GHD5.User) = (New cls_users).SelectuserbycategoryID(categoryid)

        cb.DataSource = obj
        cb.Columns.Clear()
        cb.Columns.Add("UserID").Width = 50
        cb.Columns.Add("Username").Width = 100
        cb.Columns.Add("firstname").Width = 100
        cb.Columns.Add("Lastname").Width = 150
        cb.ValueField = "Username"
        cb.TextField = "UserID"
        cb.TextFormatString = "{0},{1}"
        cb.DataBind()

    End Sub

1 个答案:

答案 0 :(得分:0)

您可以将Min()Max()用于数组和列表。

int[] array = new int[] { 1, 3, 15, 7, 9 };

int min = array.Min();
int max = array.Max();


List<int> list = new List<int>() { 1, 3, 15, 7, 9 };

int min = list.Max();
int max = list.Max();