none
Int zero tostring() is returning "000" RRS feed

All replies

  • It should return "0"

    int value = 0;
    Console.WriteLine(value.ToString());


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, November 9, 2017 10:55 PM
    Moderator
  • Hello COLEplusTEN,

    How do you use the tostring method? I think you have set custom numeric format strings for tostring method.is it something like below?

     Console.WriteLine(value.ToString(("000")));

    Sincerely,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 10, 2017 8:18 AM
    Moderator
  • This is the line of code

    set.DeductibleAmount.Value = selectedQuote.Deductible.ToString();

    which has been in our code base for years.

    Deductible is equal to int zero and after the call to ToString() DeductibleAmount.Value is being set to "000." No special numeric format is being used.

    Friday, November 10, 2017 2:49 PM
  • I suspect that it might be your Value property on DeductibleAmount that is formatting the number.

    Posting the type definition of DeductibleAmount and Value along with the Deductible property type would be useful.


    Michael Taylor http://www.michaeltaylorp3.net

    Friday, November 10, 2017 3:08 PM
    Moderator
  • DeductibleAmount is just a string inside a custom class.
    Friday, November 10, 2017 4:01 PM
  • Is Deductible a simple int? i.e. not some custom class that acts like an int but overrides ToString().

    And you're sure the property setter for DeductibleAmount.Value has no formatting code in it?

    Have you put a debug breakpoint on that line of code and tried stepping in?

    Friday, November 10, 2017 4:11 PM
  • DeductibleAmount cannot be just a string. Strings don't have a Value property.

    set.DeductibleAmount.Value

    Please post the type definitions.


    Michael Taylor http://www.michaeltaylorp3.net

    • Proposed as answer by Fei HuModerator Wednesday, November 15, 2017 10:25 AM
    Friday, November 10, 2017 4:13 PM
    Moderator
  • Please show us the relevant parts (get/set for DeductibleAmount and Deductible) of your custom class ...

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, November 11, 2017 3:56 PM
    Moderator