Finding Character Count of String in C#

We use the "Length" method to find how many characters a string consists of, or in other words the number of characters.

Let's examine the code below.

namespace ConsoleApplicationTest
{
    class Program
    {
        static void Main(string[] args)
        {

            string str = "yazilim";

            int myCount = str.Length;

            Console.WriteLine(myCount);
            Console.ReadLine();


        }
    }
}

Since our "yazilim" string consists of 7 characters, the value 7 is assigned to our variable and this result is printed on the screen.



You May Interest

C# Finding Cosine of an Angle

C# Finding the Operating System Username

C# Non-Restart Check If Application is Open

C# Finding the Path to My Documents Folder

C# Generating Random Letters