Converting a Number to a String in C#:
In C#, many methods are there to convert a number to a string. The simple one that we use the ToString()
method, which is available for all numeric data types. This method is used to convert the numeric value to its equivalent string representation.
using System;
class Program
{
static void Main(string[] args)
{
// Define a number
int number = 102;
// Convert the number to a string
string strNumber = number.ToString();
// Display the result
Console.WriteLine("Number as string: " + strNumber);
}
}
Output:
Number as string: 102
Comments (0)