05 Feb C# – Strings
The string type in C# is used to store a sequence of characters, for example, amit, john, sachin, etc. Declare a string variable using the string keyword. The string variable value is surrounded by double quotes.
Create a String
To create a String, use the string keyword. This declares a string. Let us see an example to declare and initialize a string:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
using System; namespace Demo { class Studyopedia { static void Main(string[] args) { // string variable string s = "Jack"; Console.WriteLine("Favourite Actor = {0}", s); } } } |
Output
1 2 3 |
Favourite Actor = Jack |
No Comments