Mohanapriya R Mohanapriya R
Updated date Jun 27, 2024
In this article, we will learn how to convert numbers to strings in C#.
  • 1.1k
  • 0
  • 0

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)

There are no comments. Be the first to comment!!!