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

  • Home
  • SEARCH
  • 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 595843
In Process

The Archive Base Latest Questions

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

Does anyone know whether a double is implicitly cast to double? ( Nullable type)

  • 0

Does anyone know whether a double is implicitly cast to double? (Nullable type)

EDIT: What exactly is going on here?

double d = 5;

double? d2 = d as double?
  • 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:06:25+00:00Added an answer on May 13, 2026 at 4:06 pm

    What exactly is going on here?

    double d = 5;
    double? d2 = d as double?;
    

    Well, let’s go through it.

    In the first line, you declare a local variable named d of type double. You assign the constant integer 5 to it. The compiler converts the constant integer 5 to the double 5.0 for you and generates code which assigns the value to the local.

    In the second line you declare a local variable named d2 of type double?.

    The expression “d as double?” is equivalent to “d is double? ? (double?)d : (double?) null” except of course that “d” is only evaluated once.

    The portion of that which reads “d is double?” is evaluated as true, because d is known to be of type double. (When asked “x is y”, if x is of a non-nullable type and y is the corresponding nullable type then the result is always true.)

    The compiler knows this and therefore discards the alternative “(double?) null”. Therefore the code generated is as though you’d said

    double? d2 = (double?)d;
    

    This is generated by calling the constructor of double?, passing in d as the argument to the constructor, and a reference to local variable d2 as “this”. So this becomes essentially:

    double? d2 = new Nullable<double>(d);
    

    That is exactly what is going on there. Does that all make sense?

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

Sidebar

Ask A Question

Stats

  • Questions 538k
  • Answers 538k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Apparently you're already in JSF context. Remove the /faces prefix… May 17, 2026 at 2:06 am
  • Editorial Team
    Editorial Team added an answer I found the reason for this problem. Although searching through… May 17, 2026 at 2:06 am
  • Editorial Team
    Editorial Team added an answer The only solution I'm aware of is to convert to… May 17, 2026 at 2:06 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Does anyone know whether a DOM Node of type Text is guaranteed not be
Does anyone know whether there's a way to mock Entity Data Provider so Unit
Does anyone know whether it is possible to make rewrite rules which use the
Does anyone know whether it is possible (theoretically or in reality) to use the
Does anyone know whether I can set a session value for the current domain,
Does anyone know whether the iPhone supports or will soon support the W3C Geolocation
Does anyone know whether it is possible to play a video that was synched
Does anyone know whether, in C++11, function templates can be partially specialized?
Does anyone know whether I can put paypal fees onto the buyer - so
I've found some contradicting information on the net. Does anyone know whether Hibernate filters

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.