2011-08-23 83 views
0

内的枚举值我试过下面的代码,但它始终没有返回,它应该进入搜索枚举

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 

谢谢。

+0

我所要做的就是'Enum.IsDefined()'方法:) – Tarik

回答

0

不管怎么说,

我已经找到了答案:

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