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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:21:45+00:00 2026-05-13T16:21:45+00:00

What is the basics of conversion of Not Nullable type to Nullable type? What

  • 0

What is the basics of conversion of Not Nullable type to Nullable type?

What happens inside CLR ?

is value type is internally converted to reference type?

int i = 100;

and int ? i = 7?

is both are value 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-05-13T16:21:46+00:00Added an answer on May 13, 2026 at 4:21 pm

    Run this to see that the int? is a value type:

    class Program
    {
        static int? nullInt;
    
        static void Main(string[] args)
        {
            nullInt = 2;
            Console.WriteLine(string.Format("{0} + 3 != {1}", nullInt, DoMath(nullInt , 3).ToString()));
            Console.WriteLine(string.Format("{0} * 3 = {1}" , nullInt , DoMultiply(nullInt , 3).ToString()));
    
            nullInt = null;
            Console.WriteLine(string.Format("{0} + 3 != {1}" , nullInt , DoMath(nullInt , 3).ToString()));
            Console.WriteLine(string.Format("{0} * 3 = {1}" , nullInt , DoMultiply(nullInt , 3).ToString()));
    
            Console.ReadLine();
        }
    
        static int? DoMath(int? x , int y)
        {
            if (x.HasValue)
            {
                return (++x) + y;
            }
            else
                return y;
        }
    
        static int DoMultiply(int? x , int y)
        {
            if (x.HasValue)
            {
                return (int)x * y;
            }
            else
                return 0;
        }
    }
    

    I have found these to be very interesting and makes for some clever uses.

    What ? does is create a nullable reference to an otherwise non-nullable value type. It is like having a pointer that can be checked – HasValue (a boolean value)? Nice thing about the Nullable< T > is that the Value property does not need to be cast to it’s original type – that work is done for you inside the nullable struct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

C++11 added some new string conversion functions: http://en.cppreference.com/w/cpp/string/basic_string/stoul It includes stoi (string to int),
Back to the basics... For reference types, one can do this: SomeType someObject =
The basics have already been answered here . But is there a pre-built PHP
The basics: I have a contact form that uses php to validate the forms.
I'm testing the basics for exchanging rest messages between a asp.net mvc site and
To learn the basics of OCaml, I'm solving one of the easy facebook engineering
I understand the basics of networking such as Lan and stuff. I know what
I’ve got the basics of a content rotator done, the only problem is it
I understand the basics of Rx. Where I'm struggling is how you would actually
I've gotten to grips with the basics of Python and I've got a small

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.