且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通用函数的(对T是什么?)接受字符串,整数,日期时间?

更新时间:2022-06-22 09:31:59

由于无益,因为这可能是,AFAIK有没有办法来解决它与泛型。

As unhelpful as this may be, AFAIK there's no way to get around it with generics.

为什么不直接用对象工作?它是一个性能问题?

Why not just work with Object? Is it a performance issue?

Public Shared Function GetQueryStringValue(ByVal queryStringVariable As String, ByVal t As Type) As Object
    Dim queryStringObject As Object = Nothing
    If queryStringVariable <> Nothing Then
        If HttpContext.Current.Request.QueryString(queryStringVariable) IsNot Nothing Then
            queryStringObject = CTypeDynamic(queryStringVariable, t)
        End If
    End If

    Return queryStringObject
End Function