Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:26:43+00:00 2026-06-03T14:26:43+00:00

Note: I am not trying to determing whether or not a generic parameter is

  • 0

Note: I am not trying to determing whether or not a generic parameter is nullable. What I want to know is, if it is nullable, what is the nullable’s underlying type?

Here is what I am trying:

Function CreateTdParameter(Of T)(Name As String, Value As T) As TdParameter

    Dim TdType As TdType
    Dim ValueType As Type = GetType(T)

    If ValueType.IsGenericType Then
        Dim GenType As Type = ValueType.GetGenericTypeDefinition()
        If GenType = GetType(Nullable(Of )) Then
            ValueType = Activator.CreateInstance(GenType.MakeGenericType(New Type() {ValueType}))
            ValueType = Nullable.GetUnderlyingType(ValueType.GetGenericTypeDefinition().UnderlyingSystemType)
        End If
    End If

    If ValueType = GetType(String) Then
        TdType = Teradata.Client.Provider.TdType.VarChar
    ElseIf ValueType = GetType(Integer) Then
        TdType = Teradata.Client.Provider.TdType.Integer
    ElseIf ValueType = GetType(DateTime) Then
        TdType = Teradata.Client.Provider.TdType.Timestamp
    Else
        Throw New NotImplementedException(String.Format("{0} not expected.", Value.GetType))
    End If

    Return CreateTdParameter(Name, Value, TdType, ParameterDirection.Input)

End Function

It results in the following error when a DateTime? is passed through the Value parameter:

GenericArguments[0], 'System.Nullable1[System.DateTime]’, on ‘System.Nullable1[T]' violates the constraint of type 'T'.

It appears that I need to get the underlying type in order to instantiate a nullable of that type using reflection. Not sure how to get around this catch-22.

Can anyone point me to a way that I can tell whether or not a generic type is nullable and, if it is, how I can get its underlying type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:26:45+00:00Added an answer on June 3, 2026 at 2:26 pm

    I’ll use C# for the example:

    Type underlyingType = Nullable.GetUnderlyingType(typeof(T));
    if(underlyingType != null) {
        .. is nullable, with underlying-type as described
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: this is NOT about concurrency. This is about the thread macro. I know
I'm trying to determine whether or not two strings match, and even though when
In C++, how do I combine (note: not add) two integers into one big
I wrote a custom control inherited from WebControl. (Note: not a user control). using
Note: this is not real information: $ ssh-keygen -t rsa -C "tekkub@gmail.com" Generating public/private
Note - I do not have access to a database and cannot use PHP,
Note: I'm not a newb, and I've done this a gazillion times, but for
Note: I am not exactly sure what to name the question, so if someone
Please note this is not a question about online/hosted SVN services. I am working
(note that this question is not about CAS, it's about the May fail spuriously

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.