×

C# Tutorial

Basics of .Net

C# Basics

C# Fundamentals

C# Operators

C# Loops

C# Type Conversions

C# Exception Handling

C# String Class

C# Arrays

C# List

C# Stack

C# Queue

C# Collections

C# Character Class

C# Class and Object

C# Namespaces

C# Delegates

C# Constructors

C# Inheritance

C# Operator Overloading

C# Structures

C# File Handling

C# Convert.ToInt32()

C# Int32 (int) Struct

C# DateTime Class

C# Uri Class

C# Database Connectivity

C# Windows

C# Other Topics

C# Q & A

C# Programs

C# Find O/P

Thousand Separator Program in C#

In this tutorial, we will learn how to separate the value with thousand separator using C# program? By IncludeHelp Last updated : April 09, 2023

Thousand Separator for a Number

To print a number with thousand separators in C#, we can use String.Format() function with digits placeholder (#) and commas. Below are the syntaxes of custom strings for thousand separators with and without decimal points,

// With decimal point
String.Format("{0:0,0.0}", 987654321.67)

// Wihtout decimal point
String.Format("{0:0,0}", 987654321.67)

C# program for thousand separator of a number

using System;

namespace ConsoleApplication1 {
  class Program {
    static void Main(string[] args) {
      //Thousand separator
      Console.WriteLine("Thousand Separators");

      Console.WriteLine(String.Format("{0:0,0.0}", 9876.67));
      Console.WriteLine(String.Format("{0:0,0}", 9876.67));
      Console.WriteLine(String.Format("{0:0,0.0}", 987654321.67));
      Console.WriteLine(String.Format("{0:0,0}", 987654321.67));

      Console.WriteLine();
    }
  }
}

Output

Thousand Separators
9,876.7
9,877
987,654,321.7
987,654,322

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.