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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:14:21+00:00 2026-05-23T18:14:21+00:00

In my program, I ran into a problem writing a small number to a

  • 0

In my program, I ran into a problem writing a small number to a context.Response that is then being read by a jQuery ajax response.

value = -0.00000015928321772662457;
context.Response.Write(value.ToString("#.#"));

returns [object XMLDocument]

However,

context.Response.Write(value.ToString("n"));

returns 0.00 as expected.

Using “n” is perfectly fine for my program, but why did “#.#” return with an XMLDocument?

  • 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-23T18:14:21+00:00Added an answer on May 23, 2026 at 6:14 pm

    It displays a type name probably because something’s ToString() returns null, so it instead has to display something else. You see similar behavior in Visual Studio’s Locals panel:

    1. Start a new Console Application project and replace the Program class:

        class Program {
             static void Main() {
                  var a = new Program( "asdf" );
                  var b = new Program( "" );
                  var c = new Program( null );
             } // <-- breakpoint here
      
             string _data;
             public Program( string data ) {
                  _data = data;
             }
      
             public override string ToString() {
                  return _data;
             }
        }
      
    2. Set a breakpoint at the closing brace (}) of Main() and run the project.

    3. Now look at the Locals panel. Visual Studio tries to call ToString() on objects for what to display between braces in the Value column on this panel. However, because one instance returns null, there is evidently a fallback of getting the type name:

      a      {asdf}
      b      {}
      c      {ConsoleApplication1.Program}
      

    I figure context.Response.Write() is doing something similar. Internally it uses a TextWriter, and here’s some of the process that happens in your "#.#" issue:

    1. value.ToString("#.#"), unlike value.ToString("#.0"), returns an empty string ("") because there are no non-zero digits to fill the format template (this is better than returning ".").

    2. The Write(string) method of the TextWriter calls ToCharArray(), passing that on to Write(char[]), which of course writes nothing.

    The response always produces an XMLDocument to the client-side, since XML is how AJAX transports requests and responses — even the correct "0.00" is transported in XML. Somewhere between that and your jQuery receipt of the response, something decided an empty XMLDocument should be substituted when processed. Could even be jQuery itself doing that, but I don’t know the ASP.NET pipeline or jQuery enough to find where.

    So evidently, empty AJAX responses are not so great.

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

Sidebar

Related Questions

I ran into this problem in a Visual Basic program that uses WMI but
I'm currently messing around in FORTRAN 77 and I've ran into a problem that
I ran into a problem.I'm doing a GIS program using flex. There's a map
I have recently ran into a problem that would not allow me to use
Today I ran into a problem were I needed to remote-debug a program. The
So I ran into a problem today while working on my Android program. I
We have a Perl program that ran well on all Windows platforms so far.
I ran gprof on a C++ program that took 16.637s , according to time()
I wrote a C program in Linux that mallocs memory, ran it in a
Probably everyone ran into this problem at least once during development: while(/*some condition here

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.