将Enum添加到VB.NET中的列表中

时间:2017-06-28 11:19:30

标签: vb.net list enums

这似乎是直截了当的,它应该!但是我很难将枚举添加到治疗列表中。 (我已经看过以前类似的帖子,我确实尝试过添加(EnumType.option)。没有做好工作。

Public DiseaseTreatment() As TreatmentsetDiseaseTreatment

Public Enum TreatmentsetDiseaseTreatment
'''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("01")>  _
Item01

''<remarks/>
 Antibiotics
''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("02")>  _
Item02

'''<remarks/>
<System.Xml.Serialization.XmlEnumAttribute("Pain Killers)")>  _
PainKillers




Dim temptreatment As List(Of TreatmentsetDiseaseTreatment)= New List(Of 
 TreatmentsetDiseaseTreatment)()
temptreatment.add(TreatmentsetDiseaseTreatment.Antibiotics)
temptreatment.add(TreatmentsetDiseaseTreatment.PainKillers)

这是我得到的错误:(TreatmentsetDiseaseTreatment)类型列表的值无法转换为(TreatmentsetDiseaseTreatment())

 patient.treatmentType = temptreatment

1 个答案:

答案 0 :(得分:0)

嗯,这是一个不是列表的数组,请使用temptreatment.ToArray()

patient.treatmentType = temptreatment.ToArray()