
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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%
- Related Articles
- String Formatting in Python using %?
- String Formatting in Java using %
- String Formatting Operator in Python
- How to print a complete tuple in Python using string formatting?
- String Formatting with ToString in C#
- How does string formatting work in PowerShell?
- String Formatting in C# to add padding
- Date Formatting Using printf
- Date Formatting Using SimpleDateFormat
- Formatting Text Using CSS
- Formatting a string to separate identical characters in JavaScript
- How to compare Python string formatting: % with .format?
- String Formatting in C# to add padding on the right
- Formatting day of week using SimpleDateFormat in Java
- Formatting Unordered and Ordered Lists Using CSS

Advertisements