Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajesh GamiRank #30 · 41.5K reputationPosted Nov 17, 2025, 9:31 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Nov 12, 2025, 5:40 PM EST
There are multiple suggestions to use the Int32.ToString method without a parameter but if you look at the documentation you will see that it is possible to format numbers using a parameter or two.
Int32.ToString Method
https://learn.microsoft.com/en-us/dotnet/api/system.int32.tostring?view=net-9.0
Also, the following:
Is equivalent to:
Cynthia SathuragiriRank #937 · 2.2K reputationPosted Nov 12, 2025, 11:54 PM EST
int x = 42;
string s = x.ToString(); // Converts to string
Console.WriteLine(s); // "42"
Jignesh KumarRank #91 · 22.9K reputationPosted Nov 13, 2025, 11:41 PM EST
Pankajkumar PatelRank #181 · 13.4K reputationPosted Nov 14, 2025, 12:50 AM EST
int32 to string conversion depends on programming language which is used. Following are some common examples:
C#
C++
Abhishek YadavRank #217 · 11.3K reputationPosted Nov 15, 2025, 6:15 AM EST
Mominul IslamRank #315 · 8K reputationPosted Nov 16, 2025, 6:49 AM EST
You can convert an
intto astringusing the built-in.ToString()method — the simplest and most common approach.Example:
If you want a formatted string (e.g., with commas):
Carl WalkerRank #2,515 · 558 reputationPosted Nov 17, 2025, 3:50 AM EST
use the most cleanest and direct method to convert an int (or Int32) to a string in C#.
int number = 123;
string text = number.ToString();
Sandhiya PriyaRank #26 · 43.2K reputationPosted Nov 19, 2025, 10:46 PM EST
In C#, converting an
int(Int32) to astringis very simple.Here are the most common and recommended methods:
1. Using
.ToString()(Most common & cleanest)int number = 123; string result = number.ToString();2. Using string interpolation
int number = 123; string result = $"{number}";3. Using
Convert.ToString()int number = 123; string result = Convert.ToString(number);For formatting:
Add leading zeros
int number = 7; string result = number.ToString("D4"); // output: "0007"Format with commas
int number = 1000000; string result = number.ToString("N0"); // output: "1,000,000"Quick summary:
If you want the reverse (string ? int), I can also show you the safest way using
int.TryParse().