Count textbox character and limit characters to 10

In this blog we will know how to Count textbox character and limit characters to 10.

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

namespace Count_textbox_values
{
   
public partial class Form1 : Form
   
{
       
public Form1()
       
{
           
InitializeComponent();
       
}

        private void textBox1_TextChanged(object sender, EventArgs e)
       
{
           
textBox1.MaxLength= 10;
           
lblCount.Text = "Total characters are: " + textBox1.Text.Length;
       
}
   
}
}