Create string in C#
How to define a string in C#.
The string class is used to define strings in C#.
The following code creates three strings with a name, number and double values.
string authorName = "Mahesh Chand";
string age = "33";
string numberString = "33.23";
Here is the complete example that shows how to use stings in C# and .NET.
using System;
namespace CSharpStrings
{
class Program
{
static void Main(string[] args)
{
// Define C# Strings
string authorName = "Mahesh Chand";
string age = "33";
string numberString = "33.23";
// Write to Console.
Console.WriteLine("Name: {0}", authorName);
Console.WriteLine("Age: {0}", age);
Console.WriteLine("Number: {0}", numberString);
Console.ReadKey();
}
}
}