Language
Version: 5
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
Strings
Strings
String Representation in C#
Used to return a string representation of a non-string (convert non-string to string).
Syntax
///using static method
string newString = Convert.ToString(nonString);
///called on variable directly, if type allows it
string newString2 = nonString2.toString();
Notes
Variables declared using primitive data types all have the ToString method.
Example
int number = 25;
///will assign "25" to numberAsString
string numberAsString = Convert.ToString(number);