在Enum中搜索枚举值

时间:2011-08-23 15:56:54

标签: vb.net enums

我已尝试过以下代码,但它始终没有返回任何内容,应该输入

Protected Function GetTotalDebitAmount(ByRef roEntryDetailRecordBaseList As List(Of PPDEntryDetailRecord)) As String
    Dim iTotal As Integer = 0
    If Me.BatchHeaderRecord.ServiceClassCode = Convert.ToString(CInt(ServiceClassCodes.EntriesMixedDebitsAndCredits)) Then
        For Each oEntryDetailRecord As PPDEntryDetailRecord In roEntryDetailRecordBaseList
            If CBool(Array.IndexOf([Enum].GetValues(GetType(TransactionCodes.Debits)), CInt(oEntryDetailRecord.TransactionCode)) > 0) Then
                iTotal += CInt(oEntryDetailRecord.Amount)
            End If
        Next
    End If

    Return CStr(iTotal)
End Function

我需要一个评估以下部分的人:

If CBool(Array.IndexOf([Enum].GetValues(GetType(TransactionCodes.Debits)), CInt(oEntryDetailRecord.TransactionCode)) > 0) Then

感谢。

1 个答案:

答案 0 :(得分:0)

反正,

我找到了答案:

If [Enum].IsDefined(GetType(TransactionCodes.Debits), CInt(oEntryDetailRecord.TransactionCode)) Then
                    iTotal += CInt(oEntryDetailRecord.Amount)
End If
相关问题