
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 with ToString in C#
To format a string, first set the value −
int value = 55;
Now to format the integer, use ToString and let’s say we need to set it for three places −
value.ToString("000");
The following is the complete code −
Example
using System; public class Program { public static void Main() { int value = 55; string res = value.ToString("000"); Console.WriteLine(res); } }
Output
055
Advertisements