ToString ExamplesΒΆ

Returns a string that represents the current object.

General syntax for this method:

stringName.ToString();

Example

double coffeePrice = 5.49;
string coffeeString = coffeePrice.ToString();

Console.WriteLine(coffeePrice.GetType());
Console.WriteLine(coffeeString.GetType())

Output

System.Double
System.String