Find number of characters in a String using C#

In this article we will discuss about how to find the number of characters in a string in C#.
  • 3096

The Length property of the String class returns the number of characters within a string. The following code snippet in returns the number of characters in a string.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string authorName = "Mahesh Chand Beniwal";
            Console.WriteLine("Number of characters: " + authorName.Length);
            Console.ReadLine(); 
        }
    }
}

 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.