2012-10-25 5 views
1
나는 엄격한 증명 한

엄격한 증거

[Enum].GetValues(GetType(ReferenceOutput))(DataGrid1.SelectedIndex) 

ReferenceOutput에이 vb.net 라인을 번역 문제를 데

이 될 수있는 클래스를 vb.net 라인입니다 번역 도움이 필요하고 datagrid1.selectedindex은 선택이다 DataGrid에서. 이것을 어떻게 엄격한 증명 라인으로 변환합니까? 지금 나는 followin error를 얻는다.

Error 1 Option Strict On disallows late binding. 

감사

답변

4

새로운 일반적인 방법이다 Enum.TryParse 사용하는 가장 강력한 방법은 다음과 같습니다

Dim refOutput As ReferenceOutput = DirectCast([Enum].Parse(GetType(ReferenceOutput), DataGrid1.SelectedIndex.ToString(), True), ReferenceOutput) 
:

Dim refOutput As ReferenceOutput 
Dim enumValue = DataGrid1.SelectedIndex.ToString() 
If [Enum].TryParse(enumValue, refOutput) Then 
    Console.WriteLine("Converted '{0}' to {1}.", enumValue, refOutput.ToString()) 
Else 
    Console.WriteLine("{0} is not a member of the ReferenceOutput enumeration.", enumValue) 
End If 

이 이전 자세한, 선택하지 않은 언 박싱 접근 방식을