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# How To Find The Average Of 10 Numbers Using A While Loop

C# Finding Tangent of an Angle

C# Taking Action by MessageBox OK Button

C# Non-Restart Check If Application is Open

C# Substring Method