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 6386665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:03:16+00:00 2026-05-25T03:03:16+00:00

When using the If operator ( http://msdn.microsoft.com/en-us/library/bb513985(v=VS.100).aspx ) to assign a value to a

  • 0

When using the If operator (http://msdn.microsoft.com/en-us/library/bb513985(v=VS.100).aspx) to assign a value to a System.Nullable object, if the result is Nothing (null), then 0 is assigned to the object.

Example:

'Expected value is null (Nothing). Actual value assigned is 0.
Dim x As System.Nullable(Of Integer) = If(1 = 0, 1, Nothing) 

If x is a nullable type, why is it being assigned the default integer type of 0. Shouldn’t it receive a value of null?

  • 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-05-25T03:03:16+00:00Added an answer on May 25, 2026 at 3:03 am

    Nothing in the context of a value type resolves to the default value for that type. For an integer, this is just 0.

    The If operator does not do any conversions between its argument types, they are all treated equally – as Integer in your case. Hence your code is the same as

    Dim x As Integer? = If(1 = 0, 1, 0)
    

    To make the result nullable, you need to make the types explicit.

    Dim x As Integer? = If(1 = 0, 1, CType(Nothing, Integer?))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to http://msdn.microsoft.com/en-us/library/windows/desktop/bb509610(v=vs.85).aspx HLSL supports conditional operator (since version 2.0? I am using 4_0)
im trying to write a uint128_t library (http://stackoverflow.com/questions/6119306/operator-overloading-c-placement) and ive hit a bump: i
In Lua, using the = operator without an l-value seems to be equivalent to
I'm using code from http://twitter.com/about/resources/widgets/widget_search Everything works fine, except I would like to filter
I am trying to validate a Youtube URL using regex: preg_match('~http://youtube.com/watch\?v=[a-zA-Z0-9-]+~', $videoLink) It kind
I want to print out a derived class using the operator<< . When I
I've been using the == operator in my program to compare all my strings
if I'm using the sizeof operator and making use of size_t in my code,
What is the difference between using the delete operator on the array element as
What is your opinion of using the infix operator hack in production code? Issues:

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.