In C# code I have a floating point variable number that I want presented as a string but I want it formatted in a particular way. if I have a float number, like, 0.532492829839, for example and I want it represented in C# code as "53.24%", how would I do that? I imagine it would be done using IFormatProvidre and float.parse. But I have not done it before. First of all, I guess I should multiply the number by 10, but how would I pick a number of decimal place?
complete
-2
Junior Poster
Recommended Answers
Jump to Posttextbox1.text = string.format("00.00", A.ToString()) + "%"
Why would you append a string to a string format (and your format is wrong :))
textbox1.Text = String.Format("{0:00.00}%", A.ToString());
All 4 Replies
Huntondoom
Momerath
1,327
Nearly a Senior Poster
Featured Poster
Huntondoom
nmaillet
97
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.