Convert to percentage

Posted on 2011-10-31
Last Modified: 2012-05-12
How would I convert a string to a percentage using C#?

How would I convert 85, 73,10 to a percentage?
When I divide by 100, I get .85, .73, .10.
How do I make it 85%, 73%, 10%?
Question by:Isaac
    LVL 22

    Expert Comment

    you could do a

    yourString = yourString.Replace(",", "%,");
    LVL 5

    Author Comment

    Wouldn't I then get the following results?
    %85, %73,%10
    LVL 22

    Accepted Solution

    no b/c it would look for comma placement and insert at that index replacing the comma with %,


    85%, 73%, 10

    i  guess that you would have to make sure to add a % at the very end of the string tho'
    LVL 5

    Author Comment

    if it's comma replacement, how does it get rid of the "."?

    Also, I guess I can just concatenate % at the end?
    LVL 22

    Expert Comment

    don't divide by 100 just take the whole number and apply the string replacement.

    there are a lot of ways to add at the end of the string-- choose whatever you like.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now