
- 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
C# Currency ("C") Format Specifier
The "C" (or currency) format specifier is used to convert a number to a string representing a currency amount.
Let us see an example.
double value = 139.87;
Now to display the above number until three decimal places, use (“C3”) currency format specifier.
value.ToString("C3", CultureInfo.CurrentCulture)
Let us see another example.
Example
using System; using System.Globalization; class Demo { static void Main() { double value = 234.66; // displays $ Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture)); Console.WriteLine(value.ToString("C3", CultureInfo.CurrentCulture)); } }
Output
$234.66 $234.660
- Related Articles
- C# Exponential (“E”) Format Specifier
- C# Percent ("P") Format Specifier
- C# Numeric (“N”) Format Specifier
- C# Decimal ("D") Format Specifier
- C# Hexadecimal ("X") Format Specifier
- C# Fixed-Point (“F”) Format Specifier
- Sortable ("s") Format Specifier in C#
- C# Round-trip ("R") Format Specifier
- Month ("M", "m") Format Specifier in C#
- Short Time ("t") Format Specifier in C#
- Long Time ("T") Format Specifier in C#
- Year Month ("Y") Format Specifier in C#
- Long Date ("D") Format Specifier in C#
- The "0" custom format specifier in C#
- C# General Date Short Time ("g") Format Specifier

Advertisements