In this article we will explain how to use string or what is string in c# with example.


In c# programming language string is a keyword which is used to represent a sequential collection of characters that is called a text and the string is an object of System.String type.

In c#, we use string keyword to create string variables to hold the particular text which is a sequential collection of characters.

C# String Example

Following are the different ways of declaring and initializing a string variables using string keyword in c# programming language.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SQLTutorialsPoint
    class Program
        static void Main(string[] args)
            string firstName = "Aditya";
            String lastname;                        lastname = "Kumar";
            string fullname = firstName + "" + lastname;
            Console.WriteLine("Full Name:{0}", fullname);
            //byusing string array
            string[] strarray = { "Hello", "Aditya", "Tutorials", "Point" };
            string list = String.Join(" ", strarray);
            Console.WriteLine("Message:{0}", list);


As you see above code snippet, we created a string variables using string and String keywords with or without initializing a values based on our requirements.


When we execute above c# program, we will get the result like as shown below.



 What is string in C#


In this article we have learned, how we can use string variable in c# programming language.


1. it’s an immutable

2. Performance wise string is slow because every time it will create new instance.


I hope it will help to you after reading.

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like