How to format a string of percentage format to decimal format ?

How to format a string of percentage format to decimal format ?

1    orginalValue  // value will be 1265.48
2    percentString // value after applying percentage format will be 126548 %
3    requiredvalue // value should be 1265.48
 

I converted the string from orginalValue to percentString, now i need to convert back to requiredvalue.

Is there any way to do ?

regards,

Ananth RM - msarm.com

0
msarm
2/17/2009 7:07:59 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

3 Replies
1281 Views

Similar Articles

[PageSpeed] 10

 string percentString="126548 %";

double value=double.Parse(percentString.Replace("%","").Trim()))/100;


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0
anas
2/17/2009 8:37:43 AM

or try this.

double.Parse(str.Replace(" %", string.Empty)) / 100


SHASHANK BHIDE
CAPGEMINI INDIA
"THE ROAD TO SUCCESS IS ALWAYS UNDER CONSTRUCTION MARK MY RESPONSE AS ANSWER TO HELP ME BUILD IT :)"
0
shashankgwl
2/17/2009 8:45:29 AM

Thats rite, but I looking for any built features in C# !

0
msarm
2/17/2009 10:04:30 AM
Reply:

Similar Artilces:

What are proper format strings for String.format, Number.format, etc?
Hi guys, I just started using the client side version of the Ajax framework. Everything is working out so far, except that I can't seem to be able to format any strings of numbers the way I want. Wheather I use the String.format or Number.format functions, I just keep getting Sys.FormatException errors. What are the proper format strings? I tried the relevant ones that I use in C#, but it just doesn't work.Help would be much appreciated!  I believe D, C, N, and P are the only valid ones for numbers (client side).Encosia - ASP.NET, AJAX, and more.Latest article: Using complex ...

Curency format /String.Format
   Dim subtotal As String = price * quatity 'price and  quatity  are Decimal type.  subtotal = String.Format("{0:c}", subtotal) I  want to get the sub total  in currency format  ie somedigits.twodigits (eg 100000.50), i dont want $ or any such symble before the digits. I tried the above code but it fails why?     Hey if you just want to format to 2 decimal places use {0:n2} Use the following format: {0:n2}Thanks, EdMicrosoft MVP - ASP/ASP.NET try out as         decima...

Number Format and String Format ?
Suppose I have a number "1", how can change the number format to "001" ? How can I convert the number "1" into string format "001" ? Thx for your help ~ :) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconnumericformatstrings.asp int x = 1;Response.Write(x.ToString("000"));Steven A SmithAspAlliance.com - The #1 ASP.NET CommunityDevAdvice.com - Answers to Questions If you got your data from SQL Stored Procedure, you can do the formating in your query: RIGHT('000' + CAST(Col1 AS varchar), 3) -- Tough People Do Tough Task -- It works ~ Thank you ve...

How to format a percent number as decimal using string.format in VB?
Hi, I have a GridView-Control with labels which contain numbers in percentformat, which are formatted in the RowDataBound-Event, but when I try to update the GridView i get the Invalid String format Exception because the labels are in the percentage Format like -27,5% but i need this number as double-value like 0.275. How can I convert the number from percentage to number? Any idea?  Thanks in forward,  Vlad  Dim str as string = percentlabel.Text ' Get rid of percentage sign str = str.Replace("%", "") ' Check if you can convert dim dbl as ...

Date format not formatting.
Ok so I searched previous posts to find how to remove the time stamp from the date field in grid view. So I raced to get the code put into the works, and it does not work for me. My code:<asp:BoundField DataField="SubmittedDate" HeaderText="Submitted Date" SortExpression="SubmittedDate" DataFormatString="{0:MM/dd/yy}" > Now does it matter if it's pulling form an Access DB? I have yet to switch it over to SQL for personal reasons but I really cannot see a reason why it would not be working. When it populates the field it still comes up as '11/17/2006 12:00:00am'. Am I doing some...

Format bug in String.Format() method?
I think I found a bug."{0:#0.00}" supposed to yeild 2 decimal places always right?This doesn't work (at lease not with the decimal type).  I tried multiple cases and it just doesn't do anything to the format.It's weird.  I tried "{0:#,##0.00}" and it works for ONLY values > 1000.  Anything < 1000, it doesn't do any formating whatsoever. Anyone else experience this? I don't think it is a bug."{0:#,##0.00}" works for ONLY values > 1000.It is right because you specify three '#' and one '0...

Converting from String format to date format.
I am inputting dates on a webform using a textbox. This leaves the date in string format. I want to store the date in the database as a Date format. Does anyone know how to convert the Date from String to Date format?thanks,macca Why not use the Cdate(textbox1.text) ?My Regards to All,Jason -- O-H-I-O Go Buckeyes! #1--- LIVESTRONG.ORG --- Please support the battle against cancer! Hi macca,The best approach will depend on the format that you require for the dates. Certainly the easiest format would be based on the CurrentCulture ShortDate format (M/d/yyyy for en-US). If the required date ...

FOrmating SQL DateType to String Format
I have the information below PRINT REPLACE(REPLACE(CONVERT(varchar(50), GetDate()), ' ', ''), ':', '')  What I would Like to do is run the query above  and get date of this type '2003-05-08 12:35:29.998'  returned as '20030508123529998' I know GetDate does not even come up with date in the first format so I need to know which way to get it in the first format so that I can run the query and get the second format string returned to me. Thanks in Advance.Net Web/Software Engineer  PRINT REPLACE(REPLACE(CONVERT(varchar(50...

Input string was not in a correct format for Formatted Currency
Ok, when I bind a textbox in my FormView I'm changing the format to currency (<%# Bind("TotalValue","{0:c}") %>).  When I click Update I get "Input string was not in a correct format" since TotalValue is Int32 data type. Shouldn't it convert it back to Int32 when it updates the db?  Or do I have to do it manually, and if so how? Money should not be int in the database because you need decimal places, so you use money, smallmoney, decimal and numeric for money.  Try the link below for currency related formatting in .NET.  Hope this helps.http://msdn.micro...

.NET Date Format to Oracle Data Format
 Hi,I was wondering how to change the date format of 'dd/mm/yyyy' (e.g. 11/10/2007) to the oracle date format 'dd-mmm-yyyy' (e.g. 11-Oct-2007'). Thanks.   Assuming you have a date object dt and you want a string representation in the format dd-mmm-yyyy, you can dodt.ToString("dd-mmm-yyyy") As far as the date is concerned, it is an object and has no format. A format is applied to generate a string only when you want to view it. Regards,PrashantDont forget to click "Mark as Answer" on the post that helped you. thanks for your...

How to Convert string format data in to binary Format
hai Everyone i am getting  value from string  but i unable to get it from binary.so plz tell me how to convert string format to binary Format public static byte[] ConvertStringToByteArray(string stringToConvert) {     return (new UnicodeEncoding()).GetBytes(stringToConvert); }James Wu (MIB426).NET is only way to goMCP, MCSE, MCDBA, MCSD, MCAD...

Date in string format has to be changed datetime format
I have date coming to one page as a string in the following format"May 4 2005 12:00AM" I need to query one of my tables using this date in combination of other nondate values. How can I convert this date into valid sql server datetime format before I query a database tables Please help   Hi,you can use Sql function CONVERT :convert(datetime,MYPARAM,110)scu That format will work -- depending on your locale.  The recommended date format for SQL Server is the ISO format: YYYYMMDD HH:MM:SS.MS Note that :SS.MS can be left off, or the entire time portion can be left off and t...

Dropdownlist not formatting text using String.Format()?
Any hints why the dropdownlist (.NET 3.5 ASPX web page) shows the ListItem.Text as being formated correctly, but when displayed in the dropdownlist all formatting (spaces) are removed? Code snippet:  1 With uxAllSizes 2 3 .Items.Clear() 4 5 Dim SizesDisplay As New ListItemCollection 6 7 For Each Size As DataRow In dtSizes.Rows 8 9 Dim aSize As New System.Web.UI.WebControls.ListItem 10 aSize.Value = Size("SizeID&q...

Convert .NET DateTime format to SQL DateTime format
Hi!!I'd like to know if there is a function to convert the DateTime format used in C# (VS2005) : dd/mm/yyyy HH:mm:ss to the format used in SQL Databases: yyyymmdd HH:mm:ssThanks folks!...

Web resources about - How to format a string of percentage format to decimal format ? - asp.net.web-forms

Percentage - Wikipedia, the free encyclopedia
In mathematics , a percentage is a number or ratio expressed as a fraction of 100. It is often denoted using the percent sign , "%", or the abbreviations ...

INFOGRAPHIC: Why Is Facebook’s Social Share Percentage Dropping While Pinterest, Twitter Rise?
Social sharing via Twitter and Pinterest gained 6 percent and 4 percent shares of the sector, respectively, in the third quarter of 2013 versus ...

Report: Percentage of Companies Recruiting on Facebook Stagnates, Growing Just 0.7% This Year
The 2011 Jobvite Social Recruiting Survey released today showed that 55.3% of companies now use Facebook for recruiting, up just 0.7% since 2010. ...

Restaurant Business : What percentage of restaurants have mobile websites or standard websites?
95% of independent restaurants do not have a mobile website 40% do not have menus that can be read online 50% do not even have a standard website ...

Calculator MaxiCalc Pro: with Big Retro LCD and 80's Vintage Paper Tape, Percentage, Basic and Scientific ...
Get Calculator MaxiCalc Pro: with Big Retro LCD and 80's Vintage Paper Tape, Percentage, Basic and Scientific for iPad Retina HD on the App Store. ...

RBC percentage exposure to Apple of chip suppliers March 2014 - Flickr - Photo Sharing!
Explore tiernantech's photos on Flickr. tiernantech has uploaded 1109 photos to Flickr.

What percentage of PageRank is lost through a 301 redirect? - YouTube
Roughly what percentage of PageRank is lost through a 301 redirect? Sam Harries, Exeter, United Kingdom Have a question? Ask it in our Webmaster ...


ISIS Now Controls A Shocking Percentage Of Iraq And Syria
This map from the Washington-based Institute for the Study of War is an up-to-date depiction of the operational area of the Islamic State of ...

Snail's pace: government agency ComSuper's pay offer raised 0.3 percentage point
Fears for a rushed through offer and two-tiered system at small agency.

Resources last updated: 12/18/2015 11:03:43 AM