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.