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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:37:58+00:00 2026-05-20T09:37:58+00:00

I want to do something like this but C# doesn’t accept this: public static

  • 0

I want to do something like this but C# doesn’t accept this:

    public static void setPrice(Double? value)
    {

        if (value != null) {
            this.TextBoxPrice.Text = Math.Round(value, 2).ToString();
        } else {
            this.TextBoxPrice.Text = "No Price";   
        }

    }

So does it mean using nullable type Double? is completely useless in this use case ? What can I use then ?

Update: I made a mystypo I actually meant

    public static void setPrice(Double? value)

so I corrected.

  • 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-20T09:37:59+00:00Added an answer on May 20, 2026 at 9:37 am

    You’re not currently using a nullable type – Double is a non-nullable value type, so can never be null. This is what you want:

    public static void setPrice(Double? value)
    {
    
        if (value != null) {
            this.TextBoxPrice.Text = Math.Round(value.Value, 2).ToString();
        } else {
            this.TextBoxPrice.Text = "No Price";   
        }
    }
    

    On the other hand, you should not be using a double to represent financial values. It’s inappropriate as a binary floating point type. Use decimal (or decimal?) instead.

    (Note that Double? is equivalent to Nullable<Double>.)

    If you’ve come from a Java background, you may be expecting Double to be a reference “wrapper” type to start with – it’s not. In C# double is simply an alias for System.Double; they’re the same type.

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

Sidebar

Related Questions

I want to do something like this, but the this keyword doesn't seem to
I want to do something like this, but I haven't had much success so
I want to do something like this within an MS Access query, but SUBSTRING
Hay guys, i want to use something like this users = User.objects.all() but i
I often find I want to write code something like this in C#, but
I want to do something like this: <?php echo date('Y'); ?> But then in
I want something like this: public abstract class ListenerEx<LISTENER, PARENT> implements LISTENER { PARENT
i want something like this the user enter a website link i need check
I want something like this: <msxsl:script language=C#> ??? getNodes() { ... return ... }
I want do something like this: Result = 'MyString' in [string1, string2, string3, string4];

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.