![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String Formatting in C# using %
Use the String.Fornt to format a string using %.
String.Format format controls in C# also includes percentage (%) This multiplies the value by 100 and appends a percentage sign.
Let’s say our value is −
double val = .322;
Now, use String.Format and format −
string.Format("string = {0:0.0%}", val);
The following is an example −
Example
using System; public class Program { public static void Main() { double val = .322; string res = string.Format("string = {0:0.0%}", val); Console.WriteLine(res); } }
Output
string = 32.2%
Advertisements