C# Words Count

How To Count Words In A String Using Csharp

words count in c#

In This C# Tutorial  We Will See How To Count The Number Of Words In A TextBox Text Using CSharp Programming Language And Visual Studio Editor.


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class FormDATA : Form
    {
       
        public FormDATA()
        {
            InitializeComponent();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string txt = textBox1.Text;

            char[] separator = {' '};

            int wordsCount = txt.Split(separator, StringSplitOptions.RemoveEmptyEntries).Length;

            MessageBox.Show(wordsCount.ToString());
        }
    }
}



///////////////OUTPUT:





number of words using c#



Share this

Related Posts

Previous
Next Post »