How to Use String as Variable Name in C# . In this program, we can print the name as a string in the output at C sharp programming language. A C# datatype, such as int or string, is specified by the type property, and variables are identified by the variableName property. Assigning values to a variable is done with the equal sign (=).
static void Main(string args)
string name = "Welcome to inlarn.com";
Welcome to inlarn.com
String in C#
An object of type String, a string is a collection of text. A sequential read-only collection of Char objects is used to store the text internally. An embedded null character (‘0’) can be used in a C# string because there is no terminating null character at the end.
Write() in C#
There is no new line character provided when using the Write() method. There is a new line character provided by WriteLine() at the end of the string, which sets a new line for the following output.
To print multiple objects on a single line, use the Write method. It inserts a new line character after the output has been printed. WriteLine moves the cursor to the next line while Write method keeps the cursor on the same line.