
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
Different ways for Integer to String Conversions in C#
The easiest way to convert an integer to a string in C# is using the ToString() method.
Let us see an example −
int a = 100; string str = a.ToString();
Another way is to use Convert.ToString();
b = 50; string str2 = Convert.ToString(b); Console.WriteLine(str2);
The following is the example showing the different ways to convert integer to string.
Example
using System; class Program { static void Main() { int a, b, c; a = 10; string str = a.ToString(); Console.WriteLine(str); b = 50; string str2 = Convert.ToString(b); Console.WriteLine(str2); c = 100; string str3 = string.Format("{0}", c); Console.WriteLine(str3); } }
Output
10 50 100
Advertisements