typeof(Nullable<>)
public static bool IsNullableType(Type t)
{
return t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>);
}
람다 Expressioin 매개 변수가 nullable인지 확인하기 위해이 방법을 사용했습니다.이 VB는 어떻게 표현합니까?
typeof(Nullable<>)
public static bool IsNullableType(Type t)
{
return t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>);
}
람다 Expressioin 매개 변수가 nullable인지 확인하기 위해이 방법을 사용했습니다.이 VB는 어떻게 표현합니까?
자신이 작업을 수행 할 필요가 없습니다 - 당신이 그것을 통과 유형이 널이 아닌 경우 그냥 Nothing
/null
을 반환 Nullable.GetUnderlyingType
를 사용할 수 있습니다
Public Shared Function IsNullable(t as Type) As Boolean
Return Nullable.GetUnderlyingType(t) IsNot Nothing
End Function
(하지만 당신은 정말 열린 제네릭 형식을 필요로하는 경우 다음 GetType(Nullable(Of))
작동합니다. 여러 유형 매개 변수가 필요한 경우, 단지를 쉼표로 구분 예 GetType(Dictionary(Of ,))
.)
(t.GetGenericTypeDefinition() Is GetType(Nullable(Of)))
Public Shared Function IsNullableType(t As Type) As Boolean
Return t.IsGenericType AndAlso t.GetGenericTypeDefinition() = GetType(Nullable(Of))
End Function
다음 무료 도구를 사용하여 변환 : http://www.developerfusion.com/tools/convert/csharp-to-vb/