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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:41:04+00:00 2026-05-19T03:41:04+00:00

I have come across something confusing or potentially a bug in Visual Studio 2010

  • 0

I have come across something confusing or potentially a bug in Visual Studio 2010 when defining an interface in my VB application: When defining an interface method with a default parameter of type Double, using the Double.NaN constant as the default value causes the code editor/intellisense/precompiler some issues.

The following code underlines “INaNTest” and “INaNTest.DoSomething” claiming that ‘DoSomething’ cannot implement ‘DoSomething’ because there is no matching sub on interface ‘INaNTest’:

Public Class NaNTest
    Implements INaNTest
    Public Sub DoSomething(ByVal x As Double,
                           Optional ByVal a As Double = Double.NaN)
                           Implements INaNTest.DoSomething
    End Sub
End Class

Public Interface INaNTest
    Sub DoSomething(ByVal x As Double,
                    Optional ByVal a As Double = Double.NaN)
End Interface

Removing the implementation and starting from:

Public Class NaNTest
    Implements INaNTest
End Class

Public Interface INaNTest
    Sub DoSomething(ByVal x As Double,
                    Optional ByVal a As Double = Double.NaN)
End Interface

where now “NaNTest” is underlined (Class ‘NaNTest’ must …), hitting the return key at the end of the line “Implements INaNTest” (i.e. automatically insert implementation) adds the implementation:

    Public Sub DoSomething(ByVal x As Double,
                           Optional ByVal a As Double = -1.#IND)
                           Implements INaNTest.DoSomething

    End Sub

in which the code editor then underlines ‘#’ (Identifier expected.). Thus the code automatically added code that is not right.

Alternatively now, starting with the original code above, using the Error Correction Options button on the underlined “INaNTest.DoSomething” and selecting ‘Generate method stub for ‘DoSomething’ in ‘INaNTest’, the added method stub is:

    Sub DoSomething(ByVal x As Double,
                    Optional ByVal a As Double = NaN)

where now “NaN” has been divorced from the “Double.” prefix and underlined (‘NaN’ is not declared. It may be inaccessible due to its protection level.) The code editor has inserted invalid code again.

Is there a correct solution to using Double.NaN as the default value for a method as defined on an interface, in VB.net, or is there a fundamental reason why this is impossible?

Many thanks,
JCollins

  • 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-19T03:41:04+00:00Added an answer on May 19, 2026 at 3:41 am

    Ugh, that’s fugly. Hard to characterize this as anything other than a bug. The default formatting for NaN when you let the IDE generate the method signature shows what language the VB.NET team uses, that’s the way the C++ runtime library formats NaN. Attempts to convince it you know what you are doing are indeed futile, afaict.

    You can report this at connect.microsoft.com. While you wait for the ‘fixed in the next version of Visual Studio’ to see the light of day, you might consider using nullable types as the workaround:

    Public Class NaNTest
        Implements INaNTest
        Public Sub DoSomething(ByVal x As Double, Optional ByVal a As Double? = Nothing) Implements INaNTest.DoSomething
            If a.HasValue Then
                '' etc..
            End If
        End Sub
    End Class
    
    Public Interface INaNTest
        Sub DoSomething(ByVal x As Double,
                        Optional ByVal a As Double? = Nothing)
    End Interface
    

    Fwiw, it does work when you use Double.Epsilon as the default value. Kinda silly but not an entirely unreasonable workaround either. Just don’t let the IDE generate the implementation, then it gets silly.

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

Sidebar

Related Questions

I have a Visual Studio 2008 c++03 project where I've come across something like
I'm porting an application from VB6 to VB.NET and have come across something that
Today while writing some Visual C++ code I have come across something which has
I'm new to Blackberry development and have come across something I don't understand. I
I have just come across something that is quite strange and yet I haven't
I'm new to PHP (and web development in general) and have come across something
I have come across something very similar to the following when looking for basic,
gcc 4.4.1 I am maintaining someone's code and I have come across something that
I'm working on a blog in PHP/SQL etc and I have come across something
I have come across something a little odd. I as trying to use the

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.